• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get html select's value in the bean

 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is it possible to get an html select's value in the backing bean?
e.g


can I get this select alpha's selected value in the method1 of bean1?

Thanks,
Sushma
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use h:selectOneListbox and map it to a property on the backing bean.


see http://www.exadel.com/tutorial/jsf/jsftags-guide.html
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how to get an h:selectOneMenu 's value at the back end. but problem was that I was populating this select from the javascript and even though it used to show those options on the front end, if I select any of these options, the value was coming as null... in fact, the control wouldn't even go to the back bean method and it will just refresh the same page.
So, I was looking for some other ways to get the select's value at the back end. Now, I an using a hidden field to get it's value and it is working fine.

Thanks anyways for the reply,

Sushma
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whats the reason behind using a select populated from javascript instead of a h:selectOneListBox backed by a managed-bean?
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

problem was that I had to populate this select box on the basis of selection of another select and the value in a text box. The results of this search were being displayed in this select. I am using ajax for this purpose, so I get the results back in the javascript, hence I had to populate the select box from the javascript.
is there a better way to do it?

Sushma
 
Sajan Patel
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure why you need to use this but try this you may be able to get value.


 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that, but value comes as null. that's why I used the hidden variable.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!