简体   繁体   中英

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}

SO it would read 1 - Standard Shipping

But I get an error: Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(j_id58). Found java.lang.String.

The value attribute should point to a collection of Javabeans or SelectItem objects, not to strings.

If you don't/can't change it in the Javabean or SelectItem side, then you need the to use itemLabel attribute instead.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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