Java & J2EE Page 5 - Introduction to JavaServer Faces, Part 1 |
Writing JavaBeans As noted earlier, you can bind a component to a JavaBean. In this case, the component’s local value will be copied to the JavaBean’s property if the local value is valid. To bind a component to a JavaBean’s property, you use the valueRef attribute in the custom tag representing the component. For example, to bind a UIOutput component so that it can retrieve its value from the result property of a JavaBean called testingBean, use the following: Writing Event Listeners Because JSF applications are event-driven, you need to write event listeners to determine how your applications will behave. You need to register any event listener that you want to be notified when an event is triggered by a component. To register an ActionListener with a component such as a UICommand, use the action_listener tag of the Core custom tag library inside the custom tag representing the component:
You must also write your listener class by implementing the javax.faces.event. ActionListener interface or the javax.faces.event.ValueChangedListener interfaces.
blog comments powered by Disqus |