Wednesday, May 18, 2011

Pre-populate values in h:selectManyListbox

I was able to add h:selectManyListbox on my JSF page, select some values, store in database. But while pre-populating the selected values facing issue.

But in following code h:selectManyListbox was not pre-populating the selected values.

code snippet was like this


<h:selectManyListbox styleClass="inputNameSel"

value="#{accountKeyBean.editSegment.actualValuesList}"

rendered="#{accountKeyBean.editSegment.methodType == 'Map'}">

<f:selectItems

value="#{accountKeyBean.validGLBusinessEntities}" var="misc"

itemLabel="#{misc.code}" itemValue="#{misc.code}" />

</h:selectManyListbox>


where
actualValuesList is List<MiscObject> and validGLBusinessEntities is also List<MiscObject>
I was able to populate the actualValuesList with List<MiscObject> which should be pre-selected.

I thought this will work because it was my understanding that 'value' element for h:selectManyListbox
should be of same type as that of 'value' element of f:selectItems.

I wondered, though I'm giving correct input to the actualValuesList, it is not showing the pre-selected items.

After lot of analysis, with my friend's help, could figure out that the datatype of actualValuesList should be List<String>, which worked :)

No comments:

SpringBoot: Features: SpringApplication

Below are a few SpringBoot features corresponding to SpringApplication StartUp Logging ·          To add additional logging during startup...