|
MyEclipse 下开发JSF教程(12)
The last JSP file includes a form to add and edit a book. editBook.jsp<%@ page language="Java" %> <%@ taglib uri="http://Java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://Java.sun.com/jsf/core" prefix="f" %>
<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>">
<title>Add / Edit a book</title> </head>
<body> <f:view> <h:form> <h:inputHidden id="id" value="#{bookBean.id}"/> <h:panelGrid columns="2" border="1">
<h:outputText value="Author:" /> <h:inputText id="author" value="#{bookBean.author}"> </h:inputText>
<h:outputText value="Title:" /> <h:inputText id="title" value="#{bookBean.title}"> </h:inputText>
<h:outputText value="Available:" /> <h:selectBooleanCheckbox id="available" value="#{bookBean.available}" /> </h:panelGrid>
<h:commandButton value="Save" action="listBooks" actionListener="#{bookBean.saveBook}" /> </h:form> </f:view> </body> </html>
<h:inputHidden id="id" value="#{bookBean.id}"/>Renders a HTML hidden element. Value refers to the managed bean bookBean and its property id, which indicated in the faces-config.XML. <h:panelGrid columns="2" border="1"> Renders a HTML table with two columns. <h:inputText id="author" value="#{bookBean.author}">Renders a HTML text field. Value refers to the property author of our class Book. <h:commandButton value="Save"
|