gpt4 book ai didi

java - 为什么不会 f :selectItems allow me to add another value? JBOSS/JSF

转载 作者:太空宇宙 更新时间:2023-11-04 08:35:26 24 4
gpt4 key购买 nike

我有以下代码:

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

在 f:selectItems 值属性中,我想添加 #{_shipment.shipmentMethodCode.id} - #{consoleContext.shipmentMethods}

所以它会显示为 1 - 标准运输

但是我收到一个错误:组件类型 javax.faces.SelectOne(j_id58) 需要 UISelectItem/UISelectItems 的子组件类型。找到java.lang.String。

最佳答案

value 属性应指向 Javabean 或 SelectItem 对象的集合,而不是字符串。

如果您不/无法在 Javabean 或 SelectItem 端更改它,那么您需要使用 itemLabel 属性。

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

关于java - 为什么不会 f :selectItems allow me to add another value? JBOSS/JSF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6535488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com