• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<h:selectOneMenu> issue

 
Naresh Gunda
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting exception, while retrieving the selected value of '<h:selectOneMenu>' with 'onchange' event. can you please tell me what is wrong with this code?

code in xhtml page:


code in flow:

Exception received:

I would like to pass the value of selected value 'selectOne' as the actionParam value to the flow.

Can you please tell me what is wrong with the EL expression?
 
Vaibhav Mittal
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<f:param name="state" value="#{document.getElementById('myForm.state').value}" /> I think it should be myform.states because the id for the select menu is states not state.
 
Naresh Gunda
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry! I have corrected the typo.


still I am getting ELException.

 
Vaibhav Mittal
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not think you can pass a javascript function in a value expression. The value tag expects EL expression. You do not need to pass any parameter. You can retrieve the value by calling the getState as the new value for the state would already have been set. So just skip the whole line
<f:param name="state" value="#{document.getElementById('myForm.state').value}" />
and use getState() where ever you need the state selected. It should work.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vaibhav is correct. EL value expressions must refer to server-based objects, and JavaScript works on client-based objects.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic