2

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>
4

2 回答 2

3

<f:param>您可以使用方法表达式(对于 JSF 2.0)、或、或 <f:attribute>、或,将参数从 JSF 页面传递到支持 bean 的操作方法 f:setPropertyActionListener

您可以参考http://www.mkyong.com/jsf2/4-ways-to-pass-parameter-from-jsf-page-to-backing-bean/进行参考。

于 2011-02-10T09:10:01.710 回答
0

尝试这样的事情:

<h:form> 
  <h:selectOneMenu value="#{foo.theChosenValue}"
    required="true" valueChangeListener="#{foo.processValueChange}"
    onchange="this.form.submit();">
        <s:selectItems
                       value="#{userAction.roleArray}"
                       var="role" label="#{role}"
                       noSelectionLabel="Please select" />
     <s:convertEnum />
  </h:selectOneMenu>
</h:form>

您的组件应该:

@Name("foo")
public class Foo {
    @Getter @Setter Enum theChosenValue; //I don't know your type

    public void processValueChange(ValueChangeEvent value) throws AbortProcessingException {
        if (value != null) {
            if (value.getNewValue() instanceof Enum) {
                this.theChosenValue = (Enum) value.getNewValue();
            }
        }
    }
}
于 2011-02-10T10:48:12.080 回答