aspose file tools
The moose likes JSF and the fly likes (JSF 1.2) From one SelectManyListBox to the other SelectManyListbox Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "(JSF 1.2) From one SelectManyListBox to the other SelectManyListbox" Watch "(JSF 1.2) From one SelectManyListBox to the other SelectManyListbox" New topic
Author

(JSF 1.2) From one SelectManyListBox to the other SelectManyListbox

Salz sack
Greenhorn

Joined: Apr 10, 2012
Posts: 4
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

Joined: Apr 10, 2012
Posts: 4
No idea?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14491
    
    7

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: (JSF 1.2) From one SelectManyListBox to the other SelectManyListbox
 
Similar Threads
selectManyListbox - IllegalArgumentException
selectManyListbox question
Problem with selectManyListbox
SelectManyListbox converter problem
selectManyListBox to add/remove user Roles