简体   繁体   English

为什么 f:selectItems 不允许我添加另一个值? JBOSS/JSF

[英]why won't f:selectItems allow me to add another value? JBOSS/JSF

I have the following code:我有以下代码:

<ui:repeat var="_shipment"
value="#{_order.orderShipmentList}">
<h:selectOneMenu value="#{_shipment.shipmentMethodCode.id}">
    <f:selectItems id="selectShipList"
        value="#{consoleContext.shipmentMethods}" />
</h:selectOneMenu>
</ui:repeat>

In the f:selectItems value attribute I want to add #{_shipment.shipmentMethodCode.id} - #{consoleContext.shipmentMethods}在 f:selectItems 值属性中,我想添加 #{_shipment.shipmentMethodCode.id} - #{consoleContext.shipmentMethods}

SO it would read 1 - Standard Shipping所以它会显示为 1 - 标准运输

But I get an error: Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(j_id58).但是我收到一个错误:对于组件类型 javax.faces.SelectOne(j_id58),需要 UISelectItem/UISelectItems 的子组件类型。 Found java.lang.String.找到 java.lang.String。

The value attribute should point to a collection of Javabeans or SelectItem objects, not to strings. value属性应该指向 Javabean 或SelectItem对象的集合,而不是字符串。

If you don't/can't change it in the Javabean or SelectItem side, then you need the to use itemLabel attribute instead.如果您不能/不能在 Javabean 或SelectItem端更改它,那么您需要使用itemLabel属性。

<f:selectItems id="selectShipList" value="#{consoleContext.shipmentMethods}" var="shipmentMethod" 
    itemValue="#{shipmentMethod.id}" itemLabel="#{shipmentMethod.id} - #{shipmentMethod.name}" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM