Guy Bashan schrieb:
Hi,
I have another problem with "immediate":
It seems like the hidden field always shows value="true" no matter
what I am doing.
The UI functionality is good. I have a link the shows: active/inactive.
But hidden field value always stays the same.
I have the same posted code:
<h:inputHidden id="active" value="#{accountUser.active}" />
<h:commandLink value="#{accountUser.active == 'true' ?
bundle['account_user.status.inactivate'] :
bundle['account_user.status.activate']}"
action="#{accountUser.setStatusActive}" immediate="true"
styleClass="linkor">
<f:param name="active" value="#{accountUser.active}" />
</h:commandLink>
My action code is:
public void setStatusActive()
{
setActive((!Boolean.valueOf(FacesUtil.getRequestParameter("active")))
+ "");
FacesUtil.renderResponse();
}
That's standard behaviour for immediate. You should read this page:
http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works
Because the command is immediate and you do renderResponse(), there is
no updateModel phase. And therefore all input fields just hold their
submittedValue internally and re-render that instead of pushing their
value to the model then reading back from the model.
As that wiki page says, "immediate" is really meant for "cancel-button"
type behaviour. Using it for any other purpose is a "hack", and can be
rather tricky. Sometimes it is necessary (JSF appears to be a bit
limited in this area) but you need to be careful. If you want different
parts of the page to effectively have different lifecycles, then perhaps
AJAX is what you really need...
Regards, Simon