JSP页面:
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<f:view>
<html>
<head>
<title></title>
</head>
<body background="../images/blue.jpg">
<h:form>
<f:loadBundle basename="com.data.analysis.resource.messages" var="messages"/>
<table align="center">
<thead >
<tr><td colsapn="2"><h:outputText value="#{messages.register_plant}"></h:outputText></td></tr></thead>
<tbody>
<tr>
<td>
<h:panelGrid columns="2">
<h:outputLabel for="userID" value="#{messages['user_name']}"></h:outputLabel>
<h:inputText id="userID" value="#{registerBean.user_ID}"></h:inputText>
<h:outputLabel for="userPassword" value="#{messages['user_password']}"></h:outputLabel>
<h:inputSecret id="userPassword" value="#{registerBean.user_Password1}"></h:inputSecret>
<h:outputLabel for="userAffirmpass" value="#{messages['user_affirmpass']}"></h:outputLabel>
<h:inputSecret id="userAffirmpass" value="#{registerBean.user_Password2}"></h:inputSecret>
<h:outputLabel for="sel_priv" value="#{messages['user_power']}"></h:outputLabel>
<h:selectOneMenu id="sel_priv" value="#{registerBean.user_Privilege}">
<f:selectItems value="#{registerBean.actionBean}"/>
</h:selectOneMenu>
<h:outputLabel for="sel_group" value="#{messages['user_coporation']}"></h:outputLabel>
<h:selectOneMenu id="sel_group" value="#{registerBean.user_Group}">
<f:selectItems value="#{registerBean.groupBean}"/>
</h:selectOneMenu>
<h:outputLabel for="sel_role" value="#{messages['user_role']}"></h:outputLabel>
<h:selectOneMenu id="sel_role" value="#{registerBean.user_Role}">
<f:selectItems value="#{registerBean.roleBean}"/>
</h:selectOneMenu>
<h:commandButton id="putOn" value="#{messages['register_puton']}" actionListener="#{registerBean.RegisterUser}"></h:commandButton>
</h:panelGrid>
</td>
</tr>
</tbody>
<tfoot>
<h:outputText value="#{messages.register_welcome}"></h:outputText>
</tfoot>
</table>
</h:form>
</body>
</html>
</f:view>
managed bean :
package com.data.analysis.security.web;
import java.util.ArrayList;
import java.util.List;
import javax.faces.event.ActionEvent;
import com.data.analysis.security.bo.ActionBean;
import com.data.analysis.security.bo.GroupBean;
import com.data.analysis.security.bo.RoleBean;
import com.data.analysis.security.bo.UserBean;
import javax.faces.model.SelectItem;
public class RegisterBackBean extends RegisterBackBaseBean
{
private String user_ID; //用户名
private String user_Password1; //密码
private String user_Password2;
private String user_Privilege; //所属组或者部门