Hi Craig,
I added the following code to init() function:
TestVC testVC = (TestVC) getBean("TestVC");
request.setAttribute("TestVC", testVC);
and I found the sub TestVC -- Page1VC is added to HTTPSevlertRequest object.
in my web application, TestVC works as super ViewController of the whole webapp.
The navigation rule in Page1 isn't displayed since it uses the informaiton of
TestVC, not Page1VC.
Thanks,
Luo
Craig McClanahan
Mon, 25 Sep 2006 11:35:52 -0700
On 9/25/06, emily chen <[EMAIL PROTECTED]> wrote:
Hi Craig, I could not receive the email from [email protected], but I
saw your response on shale user mail-archive. Why I need to add an
instance of VC as request attribute? That is good question~~{!-~~}
I thought it might be :-). In our web application, we have 10 VC that
extends TestVC, and TestVC
extends AbstractViewController. There is a header.jsp that is included in all
pages. In this header.jsp, we need to use the information of TestVC to decide
the navigation rule among pages. So we add an instance of TestVC as request
attribute, and access it in header.jsp. we don't specify a TestVC bean in
faces-config.xml file. We will find a way to solve the problem since this
is not a bug in the lastest version of shale framework.
One general approach to this kind of problem is to do what managed beans do
by default -- if there is already a bean by that name, use it; otherwise,
create a new one. In a view controller that extends AbstractViewController,
this is trivially easy to accomplish: TestVC testVC = (TestVC)
getBean("TestVC"); This will accomplish the same thing that evaluating an
expression that starts "TestVC" does ... if the bean already exists, it is
returned -- otherwise, a new one is created. This will avoid multiple
creations of the same bean, and therefore multiple fireing of the lifecycle
methods. Alternatively, since you are not actually using TestVC as a
ViewController, you could simply *not* make it extend AbstractViewController.
If you still like the convenience methods like getBean() and getValue(), make
your class extend AbstractFacesBean instead. Many thanks,
Luo
Craig
---------------------------------
Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail.