Triggering an Event by Clicking a Button or a Link
In the first version of the extendable expense types feature, I use a button to switch between the standard and the extended list. Figure 8-3 shows what it looks like.
The JSP page for this version of the entry form area is shown in Example 8-4.
<%@ page contentType="text/html" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <f:view> <h:form> Title: <h:inputText id="title" size="30" required="true" value="#{reportHandler.currentReport.title}" /> <h:message for="title" /> <br> Entry: <br> Date: <h:inputText id="date" size="8" required="true" value="#{entryHandler.currentEntry.date}"> <f:convertDateTime dateStyle="short" /> </h:inputText> <h:message for="date" /> <br> Type: <h:selectOneMenu id="type" required="true" value="#{entryHandler.currentEntry.type}"> <f:selectItems value="#{entryHandler.currentChoices}"
/> </h:selectOneMenu><h:commandButton value="Ext/Std" immediate="true"
action="#{entryHandler.toggleTypes}" />
<h:message for="type" /> <br> Amount: <h:inputText id="amount" size="8" required="true" value="#{entryHandler.currentEntry.amount}"> <f:convertNumber ...
Get JavaServer Faces now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.