• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

(JSF 1.2) From one SelectManyListBox to the other SelectManyListbox

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No idea?
 
Saloon Keeper
Posts: 28408
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Not so fast naughty spawn! I want you to know about
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic