• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How can I get in BootsFaces value from <b:selectOneMenu with javascript or jquery

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am new to JSF and such libraries as BootsFaces.
I am trying to get the value from selectOneMenu (BootsFaces) and pass it to javascript...i tried different methods but nothing works...please help :)
 
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't "get" values when you use JSF. JSF gets them for you and puts them in the backing bean automatically when the form that contains the control is submitted.

That's assuming that each and every control on the form has a valid value. JSF only updates the backing bean if each and every control on the form that was submitted has a valid value.

If you only want that one control's value to update the backing bean, you can make it an AJAX control. What AJAX actually does is submit just selected field(s) from the form. They're still subject to validation, but here again, JSF does the "get" for you.

If you only want JavaScript to use the menu's value as part of client-side logic, then you have to have some JavaScript to do so and you'd do that the same way that you would for a non-JSF page, with one very important exception. That exception is that when locating the control object on the page, its actual ID is not the simple "id=" value that you coded in the xhtml file, but is instead compounded from both that id and an aggregation of the container objects surrounding it. For example, the form's id. Use your browser's View Page Source function to see how it looks. Also, make sure that you have coded an id on that control and on each of its parents, since otherwise JSF will make up an id, and the made-up id isn't reliable.
 
Serban Cameron
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I solved it
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!