我试图将omnifaces.SelectItemsConverter
用于h:selectOneMenu
,我正在omnifaces here的网站上尝试这个例子,但它不起作用,没有选择任何对象,我正在使用
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.4</version>
</dependency>
<!-- Faces Library -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.4</version>
</dependency>
<!-- Primefaces Version 5 -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>1.8.1</version>
</dependency>
这是我的页面,其余代码是here
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:o="http://omnifaces.org/ui"
xmlns:of="http://omnifaces.org/functions"
template="/templates/template.xhtml">
<ui:define name="metadata">
</ui:define>
<ui:define name="content">
<h:form>
<p>
<b>Last selected item:</b>
<h:outputText id="selected_item"
value="#{selectItemsBean.selectedEntity.value}" />
</p>
<h:panelGrid columns="2">
<h:outputLabel for="iterator" value="Items with iterator: " />
<h:selectOneMenu id="iterator"
value="#{selectItemsBean.selectedEntity}"
converter="omnifaces.SelectItemsConverter">
<f:selectItem itemLabel="Choose item" noSelectionOption="true" />
<f:selectItems value="#{selectItemsBean.exampleEntities}"
var="entity" itemLabel="#{entity.value}" itemValue="#{entity}" />
<f:ajax render="selected_item" />
</h:selectOneMenu>
<h:outputLabel for="iterator_def_value"
value="Items with iterator (default value): " />
<h:selectOneMenu id="iterator_def_value"
value="#{selectItemsBean.selectedEntity}"
converter="omnifaces.SelectItemsConverter">
<f:selectItem itemLabel="Choose item" noSelectionOption="true" />
<f:selectItems value="#{selectItemsBean.exampleEntities}"
var="entity" itemLabel="#{entity.value}" />
<f:ajax render="selected_item" />
</h:selectOneMenu>
<h:outputLabel for="selectitems"
value="Items with SelectItem list: " />
<h:selectOneMenu id="selectitems"
value="#{selectItemsBean.selectedEntity}"
converter="omnifaces.SelectItemsConverter">
<f:selectItem itemLabel="Choose item" noSelectionOption="true" />
<f:selectItems value="#{selectItemsBean.selectItems}" />
<f:ajax render="selected_item" />
</h:selectOneMenu>
<h:outputLabel for="selectitems_array"
value="Items with SelectItem array: " />
<h:selectOneMenu id="selectitems_array"
value="#{selectItemsBean.selectedEntity}"
converter="omnifaces.SelectItemsConverter">
<f:selectItem itemLabel="Choose item" noSelectionOption="true" />
<f:selectItems value="#{selectItemsBean.selectItemArray}" />
<f:ajax render="selected_item" />
</h:selectOneMenu>
</h:panelGrid>
</h:form>
</ui:define>
所以如果有任何建议我会更聪明?