java - how to go through a List of Object -


i'm not novice java , today sucked problem 1 hour, don't know why .

my code looksas follows:

my arraylist:

    private arraylist<theme> selectedthemes; 

my loop:

for (theme selectedtheme : selectedthemes) {         system.out.println(selectedtheme.getnom());     } 

when try execute code below , receive exception:

java.lang.classcastexception: java.lang.string cannot cast com.mycompany.ecommerce.modele.catalogue.theme 

what understand exception selectedtheme string , werd me.

note when execute code :

system.out.println(selectedthemes); 

it show object of list normally.

edit

i'm not sure if code have relation issues:it's selectmanymenu has relation arraylist

<p:selectmanymenu id="advanced" value="#{jsfclient.selectedthemes}"                                        var="t"  showcheckbox="true">                         <f:selectitems value="#{jsfclient.themes}" var="theme" itemlabel="#{theme.nom}" itemvalue="#{theme}" />                         <p:column>                             <h:outputtext styleclass="ui-theme ui-theme-#{t.nom}" />                         </p:column>                         <p:column>                             <h:outputtext value="#{t.nom}" />                         </p:column>                     </p:selectmanymenu> 

jsfclient managedbean. please , thank you.

the problem in jsf, more itemvalue="#{theme}" part. jsf not able convert string representation of theme theme object.

you either have implement custom converter, described example here, or, if don't mind mixing in library, can use omnifaces' selectitemsconverter.

some additional possible strategies discussed in blog post balusc.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -