Hi Volker,
Thanks for your help.
The custom component that I have developed implements ActionSource. I
have an attribute "action" defined in the tag class for this component.
The action method bound returns null.
JSP code:
<ehr:commonTopBar action="#{commonTopBarController.processChange}"
value="#{commonTopBarController.model}"/>
ActionMethod:
public String processChange() {
//If the delegator is "Self" then the role
change needs to be taken up else role is irrelevant if the delegator
//is someone else than the person logged in as
the role drop down will be disabled
if
(CommonTopBarBean.DEFAULT_DELEGATOR.equals(_model.getCurrentDelegator().
getValue())) {
//Change the current role
_loggedUser.changeCurrentRole((String)_model.getCurrentRole().getValue()
);
}
//HACK - set the property to true indicating
that the "Go" button was indeed clicked
this._topBarSelectionChanged = true;
//Set the changed loggedUser back to the session
FacesUtils.storeInSession(LoginController.SESSION_KEY_LOGGED_USER,
_loggedUser);
return null;
}
If I correctly understand here are the steps that it follows:
1. When a link is clicked on the left nav custom component it goes
into the constructor of the component.
2. Then it restores the state
3. Before going into render response it enters invoke application
phase. It encounters a method processChange(). This method returns null.
So no new instance of the custom component should be created.
It should ideally go to encode state rather than constructing a new
component tree.
Could you please throw some more light into it?
Rgds,
Madhav
________________________________
From: Volker Weber [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 27, 2006 4:06 PM
To: MyFaces Discussion
Subject: Re: Very strange behavior - Constructor for component gets
called again after its restore state
Hi Madhav,
if the action method, which is invoked in invokeApplication phase
(between step 2 and 3) returns a value != null
a new component tree is created.
If you want to reuse the previously rendered component tree your action
should return null, or if you just want to reuse the
custom component instance add a binding attribute.
regards,
Volker
2006/12/26, Madhav Bhargava <[EMAIL PROTECTED]>:
Hi All,
I have developed a custom component. This component has only one
HtmlPanelNavigationMenu component which constructs dynamically depending
on the current role and some other factors.
The Panel is constructed properly and changes properly on role changes.
However there is a strange behavior. Let me explain:
HtmlPanelNavigationMenu is composed of HtmlCommandNavigationItem
components. Take the following example:
For those not able to see the image here is the menu:
HOME
MESSAGE CENTER
>> Messages
>> Reminders
.... and it continues
The parent is Message Center and once clicked it expands into Message
and Reminder sub menu.
Following happens when Message Center is clicked:
1. Calls the constructor for the custom component
2. Calls restoreState - at the end of this call all the children list
for this custom component is available.
3. Calls encodeBegin, encodeChildren and encodeEnd methods.
At the end the left Nav is expanded and is rendered properly.
However when Message link is clicked then the following happens:
1. Enters the constructor of the custom component
2. Enters restoreState method
3. Again enters the constructor of the same custom component
instead of invoking the encodeBegin
4. Does not enter restoreState but now it enters encodeBegin
As it is clear from Step 3 and 4 that when it enters encodeBegin it
does not have any children because it does not call restoreState the
second time. The end result is that the page for Message is displayed
but the left navigation menu vanishes completely.
Can anyone point out what is going wrong here?
Any help will be appreciated.
Thanks and Rgds,
Madhav
--
When I tell the truth, it is not for the sake of convincing those who do
not know it, but for the sake of defending those that do
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are
not to copy, disclose, or distribute this e-mail or its contents to any other
person and any such actions are unlawful. This e-mail may contain viruses.
Infosys has taken every reasonable precaution to minimize this risk, but is not
liable for any damage you may sustain as a result of any virus in this e-mail.
You should carry out your own virus checks before opening the e-mail or
attachment. Infosys reserves the right to monitor and review the content of all
messages sent to or from this e-mail address. Messages sent to or from this
e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***