| Code: |
| <?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page" 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:ice="http://www.icesoft.com/icefaces/component" xmlns:x="http://java.sun.com/jsp/jstl/xml"> <jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1" /> <f:view> <ice:outputDeclaration doctypeRoot="html" doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN" doctypeSystem="http://www.w3.org/TR/html4/loose.dtd" /> <html> <head> <title>Home Page</title> <link rel="stylesheet" type="text/css" href="./xmlhttp/css/xp/xp.css" /> </head> <body> <!--<f:loadBundle basename="com.attila.util.MessageBundle" var="bundle" />--> <ice:outputText value="Thank you for using Attila." /> <ice:form id="loginForm" partialSubmit="true"> <ice:panelGrid border="1" columns="2"> <ice:outputLabel for="userName"> <ice:outputText value="User Name" /> </ice:outputLabel> <ice:inputText action="#{UserBean.loginUser}" value="#{UserBean.userName}" id="userName"> <!--<f:validator validatorId="com.attila.web.jsf.validator.UserName" />--> </ice:inputText> <!--<ice:message for="userName"/>--> <ice:outputLabel for="password"> <ice:outputText value="Password" /> </ice:outputLabel> <ice:inputSecret action="#{UserBean.loginUser}" id="password"></ice:inputSecret> <!--<ice:message for="password" />--> <ice:panelGroup> </ice:panelGroup> <ice:commandButton value="Login" action="#{UserBean.loginUser}" id="submit" /> </ice:panelGrid> <ice:messages /> </ice:form> </body> </html> </f:view> </jsp:root> |
| Code: |
| backing bean :i am pasting here only the action method
public String loginUser() { FacesContext facesContext = FacesContext.getCurrentInstance(); if("myeclipse".equals(getUserName()) && "myeclipse".equals(getPassword())) { return"success"; } FacesMessage facesMessage = new FacesMessage( "You have entered an invalid user name and/or password"); facesContext.addMessage("loginForm", facesMessage); return "failure"; } |
| Code: |
| <?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page" 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:ice="http://www.icesoft.com/icefaces/component" xmlns:x="http://java.sun.com/jsp/jstl/xml"> <jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1" /> <f:view> <ice:outputDeclaration doctypeRoot="html" doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN" doctypeSystem="http://www.w3.org/TR/html4/loose.dtd" /> <html> <head> <title>Home Page</title> <link rel="stylesheet" type="text/css" href="./xmlhttp/css/xp/xp.css" /> </head> <body> <!--<f:loadBundle basename="com.attila.util.MessageBundle" var="bundle" />--> <ice:outputText value="Thank you for using Attila." /> <ice:form id="loginForm" partialSubmit="true"> <ice:panelGrid border="1" columns="2"> <ice:outputLabel for="userName"> <ice:outputText value="User Name" /> </ice:outputLabel> <ice:inputText action="#{UserBean.loginUser}" value="#{UserBean.userName}" id="userName"> <!--<f:validator validatorId="com.attila.web.jsf.validator.UserName" />--> </ice:inputText> <!--<ice:message for="userName"/>--> <ice:outputLabel for="password"> <ice:outputText value="Password" /> </ice:outputLabel> <ice:inputSecret action="#{UserBean.loginUser}" id="password"></ice:inputSecret> <!--<ice:message for="password" />--> <ice:panelGroup> </ice:panelGroup> <ice:commandButton value="Login" action="#{UserBean.loginUser}" id="submit" /> </ice:panelGrid> <ice:messages /> </ice:form> </body> </html> </f:view> </jsp:root> |
| Code: |
| backing bean :i am pasting here only the action method
public String loginUser() { FacesContext facesContext = FacesContext.getCurrentInstance(); if("myeclipse".equals(getUserName()) && "myeclipse".equals(getPassword())) { return"success"; } FacesMessage facesMessage = new FacesMessage( "You have entered an invalid user name and/or password"); facesContext.addMessage("loginForm", facesMessage); return "failure"; } |