1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:util="http://java.sun.com/jsf/composite/components/util"> <util:login loginPrompt="#{msgs.loginPrompt}" namePrompt="#{msgs.namePrompt}" passwordPrompt="#{msgs.passwordPrompt}" loginButtonText="#{msgs.loginButtonText}" loginAction="#{user.login}" managedBean="#{user}"/> </ui:composition> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- Usage: <util:login loginPrompt="#{msgs.loginPrompt}" namePrompt="#{msgs.namePrompt}" passwordPrompt="#{msgs.passwordPrompt}" loginButtonText="#{msgs.loginButtonText}" loginAction="#{user.login}" managedBean="#{user}"> <f:actionListener for="loginButton" type="com.clarity.LoginActionListener"/> </util:login> managedBean must have two properties: name and password. The loginAction attribute must be an action method that takes no arguments and returns a string. That string is used to navigate to the page the user sees after logging in. This component's loginButton is accessible so that you can add action listeners to it, as depicted above. The class specified in f:actionListener's type attribute must implement the javax.faces.event.ActionListener interface. --> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:composite="http://java.sun.com/jsf/composite"> <!-- INTERFACE --> <composite:interface> <!-- PROMPTS --> <composite:attribute name="loginPrompt"/> <composite:attribute name="namePrompt"/> <composite:attribute name="passwordPrompt"/> <!-- LOGIN BUTTON --> <composite:attribute name="loginButtonText"/> <!-- loginAction is called when the form is submitted --> <composite:attribute name="loginAction" method-signature="java.lang.String login()" required="true"/> <!-- You can add listeners to this actionSource: --> <composite:actionSource name="loginButton" targets="form:loginButton"/> <!-- BACKING BEAN --> <composite:attribute name="managedBean" required="true"/> </composite:interface> <!-- IMPLEMENTATION --> <composite:implementation> <div class="prompt"> #{cc.attrs.loginPrompt} </div> <!-- FORM --> <h:form id="form"> <h:panelGrid columns="2"> <!-- NAME AND PASSWORD FIELDS --> #{cc.attrs.namePrompt} <h:inputText id="name" value="#{cc.attrs.managedBean.name}"/> #{cc.attrs.passwordPrompt} <h:inputSecret id="password" size="8" value="#{cc.attrs.managedBean.password}"/> </h:panelGrid> <p> <!-- LOGIN BUTTON --> <h:commandButton id="loginButton" value="#{cc.attrs.loginButtonText}" action="#{cc.attrs.loginAction}"/> </p> </h:form> </composite:implementation> </html> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |