Guy Bashan schrieb:

Hi,

I'm having a weird issue with "immediate". I have 2 commandLinks. One is always rendered and one is not. When pressing the link a state is shifted from "active" to "inative".

Both links are "immediate". My bean is request scope.

For some reason, when pressing the link the first time, everything is working fine and the link is change from "active" to "inactive" But when pressing the link the second time, I see validation errors, and all fields with "required=true" are showing "Field must have value" error message.

By the way, I check, and the action is simply not called. It is not the case, when action is called but validation still shows error…

This is the JSF code:

<h:inputHidden id="active" value="#{accountUser.pubUser.isActive}" converter="BooleanConverter" />

<h:commandLink value="#{bundle['account_user.status.activate']}" rendered="#{not accountUser.pubUser.isActive}" action="#{accountUser.setStatusActive}" immediate="true" styleClass="linkor" />

<h:commandLink value="#{bundle['account_user.status.inactivate']}" rendered="#{accountUser.pubUser.isActive}" action="#{accountUser.setStatusInactive}" immediate="true" styleClass="linkor" />

This is the code of my bean:

public void setStatusActive()

{

pubUser.setIsActive(true);

FacesUtil.renderResponse();

}

public void setStatusInactive()

{

pubUser.setIsActive(false);

FacesUtil.renderResponse();

}

Anyone has a clue?

Thanks,

Guy.

I would guess that this is the commonly-encountered problem where the "rendered" flag is evaluating to false on postback. When a component's rendered state is "not rendered" on postback, then it ignores all input - even if it *was* rendered during the previous render phase.

It's not clear to me whether this is the correct behaviour (ie what the spec says) but it is certainly what MyFaces does, and always has done. It would be great if someone has time to check the specification and see what it actually says about handling the rendered state during postback...

Regards,
Simon

Reply via email to