• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trying to create drop down list in jsf using <h:selectOneMenu

 
Amul Sree
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a drop down list in jsf. My bean has a getter method which fetch the list of the beans other than the current bean. I need to display only a property from that bean in a drop down list. Please help me on this. I get this error: Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(j_id688). Found com.fhlbny.derivative.domain.FaPrincipiaCntrprty.

My xhtml is :



and bean class is


 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that if your collection type isn't SelectItem, then you need to specify an itemLabel attribute in addition to itemValue. There might be some others you need to add as well. See here.

Also, cntrprtyCode? Really? There's got to be a better name for it than that! Always keep in mind that someone else will read and want to understand your code someday, or it could even be you six months from now. Seeing a variable like cntrprtyCode is going to cause them (or you) to tear their hair out.
 
Amul Sree
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You so much for the reply!
Actually the naming is provided based on the company standard abbreviations. Those should be followed. So cant help it from my side.
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, great. Company-mandated obfuscation.

How about the <h:selectOneMenu>? Did you get that working?
 
Amul Sree
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Thank You.

The solution is instead of using <f:selectItems i used <s:selectItems and changed the List type to String.
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, that's a Seam tag, right? It's been a long time since I've seen that!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!