2

と書いてあるものが<h:selectOneMenu>入ってい<a4j:support>ます。<a4j:support>現在選択されている値をパラメーターとしてアクションに渡す必要があります。これどうやってするの?

<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>Method 式 (JSF 2.0 の場合) ,or ,or <f:attribute>, orを使用して、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 に答える