jsf - Setting Default selection on selectOneMenu via Bean -


this seams easy problem, perhaps i'm missing something. i'm trying prepopulate user field in search filter current logged in user. role filter being populated expected, user field defaults blank. i've set log statement in bean, , verifies bean being set. i've done search within gotobasicsearch function, , searches based on current logged in user.

the dropdown being populated correctly, , selecting user , searching works correctly. know why ui isn't populating field default value. technology stack: seam 2.3, jboss 7, jsf 2, richfaces 4

bean:

@name( "searchaction" ) @scope( scopetype.conversation ) public class searchaction     {     private searchfilter searchfilter = new searchfilter;     // other stuff      @begin(join = false )     public string gotobasicsearch()         {          searchfilter.setrole( roles.any );          searchfilter.setstaff( user.getstaff() );          return search;         } 

xhtml

<!-- normal stuff --> <h:selectonemenu required="false" value="#{searchaction.searchfilter.staff}">     <s:selectitems  id="stafffield" var="_selection" label="_selection.fullname" value="#{allstaff}" noselectionlabel=""/>     <f:converter converterid="converter.staff"/> </h:selectonemenu> <h:selectonemenu id="rolefield" required="false" value=#{searchaction.searchfilter.role}">     <s:convertenum />     <s:selectitems id="rolefield" var="_selection" label="#{_selection.title} value=#{searchaction.rolelist}" noselectionlabel="" hidenoselectionlabel="true" itemvalue="#{_selection}" </h:selectonemenu> 

many thanks

instead of setting staff member searchfilter.setstaff(user.getstaff()); had search through list.

long id = user.getstaff().getid(); for( staff staff : stafflist )     {     if( staff.getid() == id )         {         searchfilter.setstaff( staff );         break;         }     } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -