jsf - h:commandLink f:ajax action not called when page has f:viewParam required="true" -


in web app, jsf2 (mojarra 2.1.20), there strange behaviour on page having component following snippet:

<h:commandlink ... action="#{cc.attrs.bean.next}">     <f:ajax execute="@this" render=":#{cc.clientid}" /> </h:commandlink> 

the action next() not called. i've found out problem related reason url parameter id:

<f:metadata>     <f:viewparam name="id" value="#{torneobean.idparam}" required="true" /> </f:metadata> 

when insert viewparam above problem occurs. cannot rid of it. debugging ajax request seems start, success, complete event sequence called (no errors), components render correctly rendered action not fired. there way debug situation , find out root cause of problem?

apparently haven't attached <h:message(s)> <f:viewparam id="torneo_id"> and/or aren't updating on every ajax request. otherwise have seen required validation error on it. concrete problem covered point 3 of commandbutton/commandlink/ajax action/listener method not invoked or input value not updated.

as cause, <f:viewparam> executed on every single http request, on ajax postbacks. when ajax request sent, desired request parameter not present anymore in current request , hence <f:viewparam> fails required validation.

there several solutions this:

  1. retain request parameter subsequent request <f:param> in command component.

    <h:commandlink ...>     ...     <f:param name="id" value="#{param.id}" /> </h:commandlink> 
  2. make required during non-postback only. works if page opened request. if it's opened non-redirect navigation, still fail.

    <f:viewparam ... required="#{not facescontext.postback}" /> 
  3. replace <f:viewparam> 1 provided jsf utility library omnifaces, <o:viewparam>. implicitly turns off required="true" on postbacks kan keep using same attributes.

    <o:viewparam ... required="true" /> 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -