More Related Content Similar to Java Server Faces 1.2 presented (2007) (20) More from Peter Antman (20) Java Server Faces 1.2 presented (2007)24. Building blocks <f:view> <h:form> <h:outputText value="#{test2.value}" <h:inputText value="#{test2.value}" <h:commandButton action="#{test2.valueUpdated}" </h:form> Submit UIForm <navigation-rule> <navigation-case> <from-outcome>login <to-view-id>/login.jsp Browser JSP Component Tree <faces-config> faces-config Request Response value binding method binding 1. Restore View 2. Apply Request Values 3. Process Validation 4. Update Model Values 5. Invoke Application 6. Render Response UIViewRoot UIOutput UIInput Converter Validator ActionEvent getValue() setValue() valueUpdated() UICommand <managed-bean> <managed-bean-name>test2 <managed-bean-class>Test2 <managed-bean-scope>session RenderKit Navigation Handler Faces Servlet 30. Use a message for the element where any errors will appear <h:inputText id="in" value="#{test2.value}"> <f:validateLength minimum="2" maximum="4"/> </h:inputText> <h:message for="in" /> 83. May use J2EE annotations for life cycle callback, resource and EJB reference injection 98. According to doc a “default” bundle should be possible to use, i.e myBundle.properties. That is not my experience. A default en locale but a swedish one available gives the following: curl -v -H "Accept-Language:fr" < Content-Language: en Meddelande 1 <input (from myBundle_sv) 105. implemented using a component library that adds AJAX capability to existing pages without writing any JavaScript code 114. Ajaxifyed JSF page <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <f:view> <h:form> <h:outputText id="out" value="#{test2.value}"/> <h:inputText id="in" value="#{test2.value}"> <a4j:support event="onkeyup" reRender="out" /> </h:inputText> <h:message for="in"/> </h:form> </f:view> 122. May use EL such as #{myBean.value} almost anywhere 127. Facelets template <!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:ui="http://java.sun.com/jsf/facelets "> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Demo</title> <style type="text/css"> body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; } </style> </head> <body> <h1> < ui:insert name="title" >Default Title</ui:insert> </h1> <p> < ui:insert name="body" >Default Body</ui:insert> </p> </body> </html> 128. Facelets example <!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:ui="http://java.sun.com/jsf/facelets " xmlns:h="http://java.sun.com/jsf/html "> <body> < ui:composition template="/template.xhtml "> <ui:define name="title"> Message: #{myBean.value} </ui:define> <ui:define name="body"> <h:form id="helloForm"> <h:inputText type="text" id="userNo" value="#{myBean.value}"/> <br/> <h:commandButton type="submit" id="submit" action="success" value="Submit" /> <br/> <h:message showSummary="true" showDetail="false" style="color: red; font-weight: bold;" id="errors1" for="userNo"/> </h:form> </ui:define> </ui:composition> </body> </html> 140. * How does it work (life cycle, managed beans, ...)? 141. * Where is the connection between JSP and JSF? 142. * How does JSF compare to eg Struts or Shale? 143. * What are Facelets and why does it make sense to use it?