Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot set a value in selectOneMenu

 
Paul Smiley
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have a working snippet they can share on this? I've been hacking on this for some time, but no luck. Here's what I want to do.

I have a selectOneMenu that I wish to populate from a database. I get the values fine. However, I can't seem to set the selected item in that dropdown. It always defaults to the top one in the list. I have tried method binding, value binding and the whole 9 yards, but I can't seem to set this thing before it renders.

A related problem - when I select a value in this combo box, it changes to display the correct one. I submit the form and it goes away. It seems like something is saving the prior state and resetting it. I am not doing a save state myself.

Here's the hitch. I'm not using a simple select item - I have to carry a DB id with each select item, so I had to make a IdSelectItem subclass of SelectItem. Then I had to write a converter to display it (why it couldn't just recognize this was a subclass of SelectItem and render as such I'll never know).

If anyone has a clue on where I should go from here, I'd be grateful!

Paul
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please post your current code?
 
Paul Smiley
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't post the code - I work for BTSO (OK, those of you with kids - ever watch Jimmy Neutron with your kids? You'll know what I mean.)

My problem wasn't with the JSF code at all, it was a Hibernate mapping issue on the back end - submittedValues didn't match what was in the dropdown list.

I'm happy now...


BTW, BTSO means "Big Top Secret Organization".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic