• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ActionListener does not work.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I tried to make an ActionListener with JSF 1.2.

If I click on the Button, the new text schould be displayed in the OutputLabel. When I click the button, the ActionListener is called and finds the correct component OutputLabel.
But the problem is, that the new value is not displayed on the website.





Please help.
 
Ranch Hand
Posts: 121
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Salz,

your code is perfect and it is working as it is. If you want to see the change you made in the backing bean, you need to rerender that specific component(here outputlable). Use a4j components to implement the functionality of rerendering a component on the fly.
 
Saloon Keeper
Posts: 27762
196
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
I can't see anything wrong with the implementation from a casual look at the View and Model definition, as far as that goes.

However, I can fault the overall design. Listeners are over-used. I think a lot of that is because they were there before newer, better ways of doing things were invented and there's a lot of stale docs around.

While listeners do have their uses, the POJO method is preferable. It allows the app to be created without a lot of JSF-only code, and it reduces the coupling between Model and View. Your listener is required to know intimate details about not only JSF, but also the internal View Component structure. A POJO-equivalent design would only need to know 2 things: 1) when the button was clicked and 2) what the new label to display is.

Re-rendering is another matter. Normally, if the inputs are all valid, the action will fire and the next view displayed will be the one designated by the navigation rule. If you don't provide a rule or provide an invalid one, the current page will be re-displayed, but with the current backing data value (meaning the update label). As Suresh pointed out, you can also use AJAX to re-render only the parts of the page that have changed.
 
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
Hi,

thanks for your answers. I'll try it with the a4j components.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic