Details
Description
When the non-ajax submit button is pressed, its id and value is sent as a request parameter. If the ajax equivalent button is pressed, the id-value pair is missing. However, the id is included under the "javax.faces.source" attribute, per the spec.
This becomes a problem if you do some param checks (via binding attr.) to see if a particular button is pressed. See more info about this here: https://stackoverflow.com/a/14730658/11402059
Here's a sample of the behaviors for ajax and non ajax submissions. The required parts are in red (which should appear in both requests):
<h:form id="form1"> <div> Ajax Checkboxes: </div> <h:selectManyCheckbox id="ajaxCheckbox" required="#{not empty param[ajaxbtn.clientId]}"> <f:selectItem itemValue = "1" itemLabel = "Item 1" /> <f:selectItem itemValue = "2" itemLabel = "Item 2" /> </h:selectManyCheckbox> Message for ajaxCheckbox -> <h:message for="ajaxCheckbox" /> <br/> <div> Non-Ajax Checkboxes: </div> <h:selectManyCheckbox id="nonajaxCheckbox" required="#{not empty param[nonajaxbtn.clientId]}"> <f:selectItem itemValue = "3" itemLabel = "Item 3" /> <f:selectItem itemValue = "4" itemLabel = "Item 4" /> </h:selectManyCheckbox> Message for nonajaxCheckbox -> : <h:message for="nonajaxCheckbox" /> <br/> <!-- Added this button to see parameters passed when using ajax --> <h:commandButton id="ajaxbtn" value="Ajax Submit" binding="#{ajaxbtn}"> <f:ajax event="click" execute="@form" render="@form"/> </h:commandButton> <h:commandButton id="nonajaxbtn" value="Non Ajax Submit" binding="#{nonajaxbtn}"/> <c:forEach items="#{param}" var="entry"> <p style="#{entry.key == 'form1:nonajaxbtn' or entry.key == 'form1:ajaxbtn' ? 'color:red;' : 'color:black;'}"><h:outputText value="#{entry.key}" /> : <h:outputText value="#{entry.value}" /></p> </c:forEach> </h:form>
It used to work in 2.0, but now fails after refactoring. Haven't tested on 4.0, but I think it's also affected.
Attachments
Issue Links
- links to
(8 links to)