How to pass selected value as parameter for passing in a4j:support

Anand picture Anand · Feb 8, 2011 · Viewed 11.1k times · Source

I have one <h:selectOneMenu> inside that <a4j:support> is written. I have to pass the currently selected value through <a4j:support> as a parameter to action. How can I do this?

<rich:modalPanel>

 <a4j:form>
 <rich:dataTable value="#{factoryCollectionOfUsers}" var="foo">
 <h:selectOneMenu name="role">
                        <s:selectItems
                           value="#{userAction.roleArray}"
                           var="role" label="#{role}"
                           noSelectionLabel="Please select" />
                        <a4j:support event="onchange" ajaxSingle="true"
                           action="#{userAction.setSelection}">
                        </a4j:support>
                        <s:convertEnum />

              </h:selectOneMenu>
  </rich:dataTable>
</a4j:form>
</rich:modalPanel>

Answer

Ken Chan picture Ken Chan · Feb 10, 2011

You can pass the parameters from JSF page to the backing beans 's action method using the Method expression (For JSF 2.0) ,or <f:param> ,or <f:attribute> , or f:setPropertyActionListener .

You can refer to http://www.mkyong.com/jsf2/4-ways-to-pass-parameter-from-jsf-page-to-backing-bean/ for reference.