81,094
社区成员
发帖
与我相关
我的任务
分享
<f:view encoding="utf-8" locale="#{staff.language}">
<h:outputText value="#{staff.errMsg}" style="color:red"/><p/>
public class StaffBean {
// some code here
}
<managed-bean>
<managed-bean-name>staff</managed-bean-name>
<managed-bean-class>Staff</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
@ManagedBean(name="staff")
@SessionScoped
public class StaffBean {
// some code here
}
@ManagedBean
@SessionScoped
public class Staff {
// some code here
}
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core" template="template.xhtml">
<ui:define name="head">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</ui:define>
<ui:define name="content">
<f:view encoding="utf-8" locale="#{staff.language}">
<table width="700px" align="center">
<c:if test="${staff.language=='th_TH'}">
<tr>
<td><h:outputText value="Welcome" /><h:outputText
value=", ${staff.userName}" /></td>
</tr>
<tr></tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_description} เกรด 4 และสูงกว่าทั้งหมดควรตอบคำถาม" /></td>
</tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_description2} ประกอบด้วยคำตอบให้เลือก 10 คำถาม กรุณาอ่านคำถามอย่างรอบคอบและเลือกคำตอบที่ถูกต้อง" /></td>
</tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_passingRate} ผ่านระดับ: 8" /></td>
</tr>
<tr>
<td height="20px"></td>
</tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_fill} กรุณากรอกข้อมูลของคุณ" /></td>
</tr>
</c:if>
<c:if test="${staff.language=='zh_CN' || staff.language=='zh_HK' || staff.language=='en'}">
<tr>
<td><h:outputText value="Welcome" /><h:outputText
value=", ${staff.userName}" /></td>
</tr>
<tr></tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_description}" /></td>
</tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_description2} " /></td>
</tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_passingRate} " /></td>
</tr>
<tr>
<td height="20px"></td>
</tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_fill}" /></td>
</tr>
</c:if>
</table>
<h:form method="post" id="staffForm" prependId="false">
<table width="700px" align="center">
<tr>
<td>
<table width="80%" align="center">
<tr>
<td width="30%"><h:outputText
value="#{uic.staffInfo_region}" /></td>
<td><h:selectOneMenu id="region"
value="#{staff.staffRegion}">
<f:selectItem itemLabel="HK" itemValue="HK" />
<f:selectItem itemLabel="China" itemValue="CN" />
<f:selectItem itemLabel="Thailand" itemValue="TH" />
<f:selectItem itemLabel="Singapore" itemValue="SG" />
<f:selectItem itemLabel="Malaysia" itemValue="MY" />
<f:selectItem itemLabel="Taiwan" itemValue="TW" />
</h:selectOneMenu></td>
</tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_name}" /></td>
<td><h:inputText name="staffName" id="staffName"
value="#{staff.staffName}" required="true"
requiredMessage="Full Name is required" /></td>
</tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_staffID}" /></td>
<td><h:inputText name="staffID" id="staffID"
value="#{staff.staffNo}" required="true"
requiredMessage="Staff Number is required" /></td>
</tr>
<tr>
<td><h:outputText value="#{uic.staffInfo_division}" /></td>
<td><h:selectOneMenu id="division"
value="#{staff.staffDivision}">
<f:selectItem itemLabel="Management" itemValue="Management" />
<f:selectItem itemLabel="Store Planning"
itemValue="Store Planning" />
<f:selectItem itemLabel="Administration"
itemValue="Administration" />
<f:selectItem itemLabel="Customer Service/ Call Centre"
itemValue="Customer Service/ Call Centre" />
<f:selectItem itemLabel="Marketing" itemValue="Marketing" />
<f:selectItem itemLabel="Logistic and Inventory Control"
itemValue="Logistic and Inventory Control" />
<f:selectItem itemLabel="Sales and Merchandising"
itemValue="Sales and Merchandising" />
<f:selectItem itemLabel="Quality Assurance"
itemValue="Quality Assurance" />
<f:selectItem itemLabel="Human Resource"
itemValue="Human Resource" />
<f:selectItem itemLabel="Information Technology"
itemValue="Information Technology" />
<f:selectItem itemLabel="Finance & Accounting"
itemValue="Finance & Accounting" />
<f:selectItem itemLabel="Store Operations - Stores"
itemValue="Store Operations - Stores" />
<f:selectItem itemLabel="Store Operations - Office"
itemValue="Store Operations - Office" />
</h:selectOneMenu></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="20px"></td>
</tr>
<tr>
<td align="center"><h:commandButton type="submit"
value="#{uic.staffInfo_start}" action="#{staff.startQuiz}" /></td>
</tr>
</table>
</h:form>
</f:view>
</ui:define>
</ui:composition>
@ManagedBean(name="staff")
@SessionScoped
public class StaffBean {
// some code...
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF\applicationContext.xml;WEB-INF\applicationContext-security.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- place constraints on a single user's ability to log in to your application -->
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- DelegatingFilterProxy delegates to a filter implementation which is defined as a Spring bean in your APP
web security are configured using http element-->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
<url-pattern>/faces/*</url-pattern>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>
<resource-ref>
<description>
Resource reference to a factory for java.sql.Connection
instances that may be used for talking to a particular
database that is configured in the configurartion for the web application.
</description>
<res-ref-name>jdbc/QuizAdmin</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<?xml version="1.0" encoding="utf-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>th</supported-locale>
<supported-locale>zh_CN</supported-locale>
<supported-locale>zh_HK</supported-locale>
</locale-config>
<resource-bundle>
<base-name>com.toysrus.quiz.ui.UIControl</base-name>
<var>uic</var>
</resource-bundle>
</application>
<!--
========================= navigation-rule
=============================
-->
<navigation-rule>
<from-view-id>/staffInfo.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/showQuestion.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/staffInfo.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/showQuestion.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/checkAnswer.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/login.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>