HTML and CSS Reference
In-Depth Information
Table 4-1. Main Attributes of < f:setPropertyActionListener> Tag
Represents ValueExpression to be stored as the value of the target attribute.
Represents ValueExpression that is the destination of the value attribute.
In order to understand how to use the <f:setPropertyActionListener> tag, let's see an example. Listing 4-9
shows an example of the <f:setPropertyActionListener> tag inside a CommandButton .
Listing 4-9. An Example of <f:setPropertyActionListener>
<h:commandButton value="Say Hi" action="page2">
<f:setPropertyActionListener target="#{}" value="Some user"/>
As shown in the previous code listing, when the CommandButton is clicked, the name attribute of the Person
managed bean will be set to "Some user" and then the current page will be forwarded to page2. Listing 4-10 shows
Person managed bean.
Listing 4-10. Person Managed Bean
public class Person {
private String name;
public String getName() {
return name;
public void setName(String name) { = name;
Person managed bean is a simple bean with only one attribute name with its setter and getter. After setting the
name attribute of the Person managed bean to "Some user" using the <f:setPropertyActionListener> tag, then in
page2, if we have the following expression in the page:
Hello, #{}
This will produce
Hello, Some user
Value Change Events
A value change event is an event that is triggered when the value of a ValueHolder (or an EditableValueHolder )
component is changed. Let's see an example of a value change listener. Assume that we want to display the capitals of
set of countries that are shown in a JSF SelectOneMenu component when the user selects one of these countries and
then clicks a CommandButton to get the capital of the selected country. Listing 4-11 shows the form which includes the
country list.
Search WWH ::

Custom Search