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.
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.
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.
"privilege" comes from the Latin words for "private" and "law" (legal) and dates to feudal times. To "claim privilege" meant that you were above the laws that applied to the common people.
posted 8 years ago
thanks for your answers. I'll try it with the a4j components.
Their achilles heel is the noogie! Give them noogies tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop