• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF with Javascript  RSS feed

 
amar mahtani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my application I have two list boxes (selectOneListbox), one shows Available Items and the other shows Selected Items. I use javascript to transfer items between the two list boxes. When I click on the commandButton, the desired action method is not executed, rather the list boxes get reset to their previous state (i.e. all the items from Selected List go back to the Available List.) And when I click on the commandButton again immediately, then the action method is executed.

My doubt here is does JSF not like javascript performing a task and hence resets it when we try to submit the form. Any suggestions to work around this issue, and to be able to submit the form when I have items in Selected List and to make those items available in the backing bean. Thanks for your responses.

Amar
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever you change the options of a dropdown at the client side, you need to change this at the server side too. This because of the fact that JSF validates the selected options against the list of options as it was in initial request.

I suggest you to take a look for an ajaxical component library such as RichFaces. They have a rich:pickList component which suits your needs. Here are some useful links about that:
http://jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/html/pickList.html
http://livedemo.exadel.com/richfaces-demo/richfaces/pickList.jsf
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!