Monday, 15 June 2015

jsf 2 - Button with Immediate="true" clears currently displayed validation messages -



jsf 2 - Button with Immediate="true" clears currently displayed validation messages -

i have commandbutton redisplays page help on field. needs work without javascript. don't want trigger validation add together immediate = true. works fine, however, validation messages on page disappear, whereas want them remain there.

<h:commandbutton rendered="#{cc.attrs.helpid!= null}" styleclass="helpbutton" value="?" type="submit" action="#{visiblehelp.toggle(cc.clientid)}" immediate="true" /> ... <h:panelgroup rendered="#{visiblehelp[cc.clientid] != null}" id="#{cc.attrs.name}_helptext" styleclass="help-text"> <h:outputtext value="#{help[cc.attrs.helpid]}"/> </h:panelgroup> ...

is how is, or missing something?

that's expected behavior. faces messages request scoped. submitting form creates new request. immediate="true" input components not having attribute won't validated , hence not generate faces messages. on synchronous (non-ajax) postback, initial messages "disappear" because of total page reload.

just submit ajax instead page won't reloaded.

<h:panelgroup id="helpbutton"> <h:commandbutton rendered="#{cc.attrs.helpid!= null}" styleclass="helpbutton" value="?" action="#{visiblehelp.toggle(cc.clientid)}" immediate="true"> <f:ajax render="helpbutton helpsection" /> </h:commandbutton> </h:panelgroup> ... <h:panelgroup id="helpsection"> <h:panelgroup rendered="#{visiblehelp[cc.clientid] != null}" id="#{cc.attrs.name}_helptext" styleclass="help-text"> <h:outputtext value="#{help[cc.attrs.helpid]}"/> </h:panelgroup> </h:panelgroup>

true, involves under covers still javascript, there's no other feasible solution, or must remove immediate="true" validation re-executed input components.

jsf-2

No comments:

Post a Comment