简体   繁体   中英

how to use selectOneMenu with object in selectItems

I don`t understand how to use ArrayList of objects in f:selectitems. I use composite components and code below is not work:

<h:selectOneMenu id="kladrRegion-dctKladrRegion" 
                                     tabindex="100"
                                     value="#{cc.attrs.kladrRegion}"
                                     styleClass="comboBox ui-corner-all   inputText ui-inputfield kladrSearchFormInput kladrSearchFormSelectWidth selectHight"  
                                     style="font-size: 13px; width: 300px;"
                                     binding="#{cc.attrs.cbKladrRegion}" >
                        <f:selectItems value="#{cc.attrs.kladrRegions}" var="region" 
                                       itemLabel="#{region.value}" itemValue="#{region.id}" />                                
                        <f:ajax  
                            listener="#{cc.attrs.kladrRegionChange}" />
                    </h:selectOneMenu>

This code does not work, because the attribute var receive a new value after adding a second composite component. In the previous composite components selectOneMenu will not be displayed. How to make a drop-down list in this case?

I found solution of my problem. Follow to this post: JSF 2 composites and binding for validation

SelectOneMenu needs to have "binding" attribute with unique value. After adding second composite component Error <f:ajax> contains an unknown id

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