简体   繁体   English

JSF-selectManyListbox带有已选择的项目

[英]JSF - selectManyListbox comes with items already selected

I have a simple problem and I hope that the solution is also so simple... 我有一个简单的问题,希望解决方案也是如此简单...

The items in my selectManyListbox all comes already selected per default and I don't want this. 默认情况下,我的selectManyListbox中的所有项都已被选中,我不希望这样做。

I searched everywhere for possible options but I found nothing. 我到处搜索可能的选项,但什么也没找到。

Can someone help me, please? 有人能帮助我吗?

<h:selectManyListbox 
     value="#{detailModel.afterObject.businessObjectAttributeSpecifications}" 
     size="10"> 
    <f:selectItems 
       value="#{detailModel.getSetAsList(detailModel.afterObject.businessObjectAttribut‌​eSpecifications)}"/> 
</h:selectManyListbox>

Thank you in advance Francesco 预先感谢弗朗切斯科

You have the same list for the selectItems and the value attribute. selectItemsvalue属性具有相同的列表。 Use a different list ( such as selectedObjects ) in the value attribute to hold the selection, eg: value属性中使用其他列表(例如selectedObjects )来保存选择,例如:

<h:selectManyListbox 
     value="#{detailModel.afterObject.selectedBusinessObjectAttributeSpecifications}" 
     size="10"> 
    <f:selectItems 
       value="#{detailModel.getSetAsList(detailModel.afterObject.businessObjectAttribut‌​eSpecifications)}"/> 
</h:selectManyListbox>

添加带有文本的默认项, Please Select并对其进行编程处理

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

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