HTML and CSS Reference
In-Depth Information
Listing 2-20. The Login Action Method in the User Managed Bean
public class User implements Serializable {
public String login() {
return "welcome";
As shown in Listing 2-20, the method of the action attribute have the following signature:
Returns a String (outcome) that is used for determining the navigation.
Adding to this, if you are working with EditableValueHolder s, you can invoke a method expression from the
valueChangeListener attribute. Let's see an example to explain this. Listing 2-21 shows the beverages page, which
contains a selectOneMenu component that holds a list of beverages and an outputText to show the price of the
selected beverage.
Takes no argument.
Listing 2-21. The Beverages Page
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns=" "
xmlns:h=" "
xmlns:f=" " >
<h:outputText value="Select a beverage: " />
<h:selectOneMenu value="#{}"
<f:selectItem itemLabel="---" itemValue="---"/>
<f:selectItem itemLabel="Tea" itemValue="tea" />
<f:selectItem itemLabel="Coffee" itemValue="coffee" />
<f:selectItem itemLabel="Coca-Cola" itemValue="cocacola" />
</h:selectOneMenu> <br/><br/>
<h:outputText value="You will have to pay: #{beverage.price} USD"
rendered="#{beverage.price ne null}"/>
Search WWH ::

Custom Search