Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

(JSF 1.2) From one SelectManyListBox to the other SelectManyListbox  RSS feed

 
Salz sack
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I have the following problem:

I have to SelectManyListBoxes. In one of these the website displays numbers (1-10). When I click on one or more numbers and click on the commandbutton, the selected numbers schould be move to the second SelectManyListBox.
Do I need an ActionListener or an ValueChangeListener and how can I do that? The following code doesn't work.




And this is the actionListener.



And my Managed-Bean:

 
Salz sack
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No idea?
 
Tim Holloway
Bartender
Posts: 18713
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is better to use an action method than an actionListener. Action methods are simple POJO methods, easy to code, maintain, and test. Listeners are JSF-specific, more complicated to code and test, and more likely to be impacted if JSF makes architectural changes in the future.

I'm not sure why so many people are hung up on using Listeners. I think it's because there's old, stale documentation out on the Internet. Either that, or they can't be satisfied with a simple solution when a complicated one can be used instead. There are times when Listeners are required, but not as often as a lot of people seem to think.

As far as your particular problem goes, these conditions must be satisfied for the action to work properly.

1. All of the affected controls must be inside a JSF form.

2. When the command button is clicked, ALL controls in that form MUST have valid values. JSF is all-or-nothing, and if even a single input is invalid, ALL inputs are rejected and the action will not be fired. This ensures data integrity automatically.

3. To set the selected value of a secondary selection control from a primary control, the action method must set the secondary control's "value" property to the desired value. This value MUST be one of the values in the secondary control's selectItem collection. If it is not, it is rejected and a default value from that collection will be set. And you may also get a validation error.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!