HTML and CSS Reference
In-Depth Information
Action Events
In the previous chapters, we saw some examples of action events and action listeners with action methods. Let's recall
the first application example in Chapter 2. Listing 4-1 shows an example of an action listener with an action method
in the first application example.
Listing 4-1. An Example of an Action Listener with an Action Method in “First Application” Example
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns=" "
xmlns:ui=" "
xmlns:h=" " >
<ui:composition template="/WEB-INF/templates/simple.xhtml">
<ui:define name="title">
<ui:define name="content">
<h:commandButton value="#{bundle['application.login']}" action="#{user.login}"/>
As we see in Listing 4-1, we could create an action listener with an action method using the UICommand
( CommandButton ) action attribute. Listing 4-2 shows the #{user.login} action method code.
Listing 4-2. #{user.login} Action Method Code
public class User implements Serializable {
public String login() {
return "welcome";
As you will notice, the action method is a method which takes no arguments and returns a String that represents
the outcome.
action methods are handled by the JSF built-in default action listener. the default action listener takes the
returned outcome String from the action method and then delivers it to NavigationHandler to handle the navigation
(if there is any).
Search WWH ::

Custom Search