0

I'm having some inconsistent behaviour when combining a hidden input and a commandlink with jsf ajax.

<p:fieldset id="someFieldset">
        <h:inputHidden>
               <f:validator validatorId="myValidator"/>
               <f:attribute name="input1"
                            value="#{backingBean1.someField}"/>
               <f:attribute name="input2"
                            value="#{backingBean2.someOtherField}"/>
        </h:inputHidden>
        <p:dataTable id="someTable"
                     value="..."
                     var="someVar">
                <p:column>
                        ....
                </p:column>
                ....
                <p:column>
                        <p:commandLink id="deleteBtn"
                                       process="someForm:someFieldset"
                                       rendered="..."
                                       oncomplete="if (args &amp;&amp; !args.validationFailed {PF('someDialog').show()}">
                                 <f:ajax type="onclick" listener="#{backingBean1.setSomeField(someVar.reference)}" />
                        </p:commandLink>
                </p:column>
         </p:datatable
</p:fieldset>

The desired behaviour is the onclick event being fired first before the commandlink will process the hidden input and fire the validator.

The behaviour is however inconsistent. Sometimes the onclick will fire first and other times the validator will fire first (receiving an attribute that hasn't been set first)

Any ideas how I can guarantee the setter being called before the validator?

Annanraen
  • 21
  • 6
  • p:commandButton already has a built-in 'p:ajax', so you currently duplicate the ajax request and p:ajax has some other default as f:ajax. Also see: https://stackoverflow.com/questions/15548707/ajax-update-and-submission-using-hcommandbutton – tandraschko Aug 29 '22 at 16:05
  • it's a commandLink, not a button. That's why the ajax is there – Annanraen Sep 02 '22 at 10:59
  • 1
    thats exactly the same; commandLink is already ajaxified like commandButton. – tandraschko Sep 02 '22 at 16:24

0 Answers0