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=" http://www.w3.org/1999/xhtml "
xmlns:ui=" http://java.sun.com/jsf/facelets "
xmlns:h=" http://java.sun.com/jsf/html " >
<ui:composition template="/WEB-INF/templates/simple.xhtml">
<ui:define name="title">
#{bundle['application.loginpage.title']}
</ui:define>
<ui:define name="content">
...
<h:commandButton value="#{bundle['application.login']}" action="#{user.login}"/>
<br/><br/>
</h:form>
</ui:define>
</ui:composition>
</html>
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).
Note
 
 
Search WWH ::




Custom Search