<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>#{msgs.title}</title> </h:head> <h:body> <h:form> <p>#{quizBean.question}"/></p> <p><h:inputText value="#{quizBean.response}"/></p> <p> <h:commandButton value="#{msgs.checkAnswer}" action="#{quizBean.answerAction}"/> </p> </h:form> </h:body> </html>
The command button in this JSF page illustrates the use of an action method. The value expression in the action attribute specifies that the outcome is the returned value of the quizBean answerAction() method. Since the method has no parameters, the parentheses are omitted.
The return value of answerAction() is a logical outcome that is used to select a navigation rule in the faces-config.xml file.