You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-user@incubator.apache.org by "Baker,Jonathan" <Ba...@oclc.org> on 2006/09/08 16:12:16 UTC

ViewControllers and t:aliasBean

In my application, I have several folders.  Each folder contains
different items, butt the page for each folder is the same.  We are
using the Trinidad commandNavigationItem which displays a
ViewIdMenuModel for our navbar.  This menu model requires that each
separate tab has a different view id.  Since we are using Shale we have
a different ViewController defined for each view id.  Since each folder
page is identical, but the view id menu model requires each tab to have
a separate page, I attempted to use the tomahawk aliasBean component to
alias the ViewController bean from something specific like
"newItemsFolder" to something generic like "folder".  This way, my
folderContent.jsp just has references that look like this #{folder.***}
This idea functions correctly, but I discovered in my debugger that my
ViewController init method is getting called an outrageous number of
times when switching from one folder to the next using the navbar.  I
expected it to be called two times, once for the postback to the
original folder and once for the load of the new folder.  This is not
the case.  As the component tree is processed for each step in the
lifecycle we eventually reach the aliasBean component.  When the alias
is resolved the ViewController bean is set as the value for the alias.
Way down in the bowels of Shale-Tiger LifeCycleListener2, Shale says if
we are setting an attribute, then we need to fireRequestInit.  In the
Shale-Core LifeCycleListener, Shale says if the bean we have happens to
be an instance of ViewController then call init().  

I'm sure I could solve this problem by adding a boolean to say whether
or not we've been initted or not, but that doesn't seem like a very good
solution.  I feel a little stuck because the navbar uses the view id to
reconcile the navbar hierarchy it should render, so to use their navbar
component I need a separate page for each folder.  Unfortunately this
causes The ViewController instance to be the only thing that is variable
for a given folder page.  

Any help with this quandary would be appreciated.  Is there an
alternative to using aliasBean to switch the view controller for a given
jsp page?  I attempted using a Tiles controller to move the
ViewController into a request scope object named folder and the page
displayed correctly, but no actions worked because the TileController
runs in the RenderResponse phase, but that invokeApplication phase was
trying to find something named folder and it wasn't there yet.

Thanks,
JB