如何在我的 Bean 中获取 <f:selectItem> 的项值?



如何从'f的" itemValue"属性中获取值:selectItem itemlabel ="请求posting" itemvalue =" 1"'Div>

jsf将仅在valueUISelectMany组件的CC_1属性背后将其设置在其中,其中您使用此<f:selectItem>作为孩子。

,例如

<h:selectOneMenu value="#{bean.someProperty}">
    <f:selectItem itemLabel="Request Posting" itemValue="1" />
    ...
</h:selectOneMenu>
<h:commandButton value="submit" action="#{bean.submit}" />

它将在Invoke Action阶段(例如,在命令按钮ACTION方法中)仅作为someProperty

可用
private String someProperty; // +getter+setter
public void submit() {
    System.out.println(someProperty); // Look, JSF has already set it!
}

另请参见:

  • 我们的<h:selectOneMenu> Wiki Page

最新更新