html - selectOneListBox with size 1 appears as drop down menu -
i using h:selectonelistbox dynamically add data in it. empty. every time user presses on "add" button, entry added in list box.
i have specified particular height of list box. issue appearance of listbox when has 1 entry. appears drop down menu of specified height rather list box. if has more 1 entry, looks fine.
need know, if there way can control appearance of selectonelistbox when size 1. in below code, assume backingbean.names return 1 select item.
<div style="height: 400px"> <h:selectonelistbox id="names" style="width:100%; height:100%; " value="#{backingbean.selectedname}"> <f:selectitems value="#{backingbean.names}" /> </h:selectonelistbox> </div>
you need explicitly specify size 2 or larger, otherwise indeed default size of available select items.
<c:set var="size" value="#{fn:length(backingbean.names)}" /> ... <h:selectonelistbox ... size="#{size gt 1 ? size : 2}">
Comments
Post a Comment