(
package com
import java
import mons
public class UserInfo implements Serializable{
private String id;
private String username;
private String email;
public UserInfo(String id
this
this
this
}
public UserInfo(){
}
public UserInfo(String id){
this
}
public String getId(){
return id;
}
public void setId(String id){
this
}
public String getEmail(){
return email;
}
public void setEmail(String email){
this
}
public String getUsername(){
return username;
}
public void setUsername(String username){
this
}
public String toString(){
return new ToStringBuilder(this)
}
}
(
<?xml version=
<!DOCTYPE hibernate
<hibernate
<class name=
<meta attribute=
@hibernate
table=
</meta>
<id name=
<meta attribute=
@hibernate
generator
type=
column=
</meta>
<generator class=
</id>
<property name=
<meta attribute=
@hibernate
column=
length=
</meta>
</property>
<property name=
<meta attribute=
@hibernate
column=
length=
</meta>
</property>
</class>
</hibernate
(
package com
import com
import org
import java
public interface IUserInfoDAO extends Serializable{
public boolean setUserInfo(UserInfoVO userinfoVO)throws DataAccessException;
}
(
package com
import mons
import mons
import org
import org
import org
import com
import com
import com
public class UserInfoDAO extends HibernateDaoSupport implements IUserInfoDAO{
private static final Log log = LogFactory
public boolean setUserInfo(UserInfoVO userinfoVO)throws DataAccessException{
if(userinfoVO == null){
return false;
}
UserInfo ui = new UserInfo();
ui
ui
ui
this
return true;
}
private String getID(){
return UUIDGenerator
}
}
(
package com
import com
import org
import java
public interface IExampleManager extends Serializable {
public boolean setUserInfo(UserInfoVO userinfoVO)
throws DataAccessException;
}
(
package com
import com
import com
import com
import mons
import mons
import org
public class ExampleManagerImpl implements IExampleManager {
private static final Log log = LogFactory
private IUserInfoDAO userinfo;
public ExampleManagerImpl() {
(
}
public void setUserinfo(IUserInfoDAO userinfoDAO)
throws DataAccessException {
this
}
public boolean setUserInfo(UserInfoVO userinfoVO)
throws DataAccessException {
return userinfo
}
}
(
package com
import java
public class UserInfoVO implements Serializable{
private String username;
private String email;
public String getEmail(){
return email;
}
public void setEmail(String email){
this
}
public String getUsername(){
return username;
}
public void setUsername(String username){
this
}
}
JSF表示層
(
package com
import ntext
import mons
import mons
import orgntext
import org
import com
import com
public class InfoBean {
private static final Log log = LogFactory
private String username = null;
private String email = null;
private String response = null;
private long maximum =
private boolean maximumSet = false;
private long minimum =
private boolean minimumSet = false;
public InfoBean() {
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this
}
public String submitPersonInfo() {
(username);
(email);
ApplicationContext ac = FacesContextUtils
IExampleManager em = (IExampleManager) ac
UserInfoVO uiVO = new UserInfoVO();
uiVO
uiVO
boolean flag = em
if (flag) {
setResponse(
return
} else {
setResponse(
return
}
}
public void setResponse(String response) {
this
}
public String getResponse() {
return null;
}
public long getMaximum() {
return (this
}
public void setMaximum(long maximum) {
this
this
}
public long getMinimum() {
return (this
}
public void setMinimum(long minimum) {
this
this
}
}
(
<html>
<head>
</head>
<body>
<jsp:forward page=
</body>
</html>
(
<%@ page contentType=
<%@ taglib uri=
<%@ taglib uri=
<html>
<head>
<title>
用戶注冊
</title>
</head>
<br>
<f:view>
<h:form id=
<table border=
bordercolor=
<tr>
<td colspan=
</tr>
<tr>
<td>
<div align=
</td>
<td>
<h:inputText id=
<f:validateLength minimum=
maximum=
</h:inputText>
</td>
</tr>
<tr>
<td>
<div align=
</td>
<td>
<h:inputText id=
</td>
</tr>
<tr>
<td colspan=
<span>
<h:message id=
for=
</td>
</tr>
<tr>
<td align=
<h:commandButton id=
action=
</td>
</tr>
</table>
</h:form>
</f:view>
</html>
(
<%@ page contentType=
<%@ taglib uri=
<%@ taglib uri=
<html>
<head>
<title>
用戶注冊成功
</title>
</head>
<body bgcolor=
<f:view>
<h:form id=
<h:graphicImage id=
url=
<h
<h:outputText id=
value=
<h:commandButton id=
value=
<p>
</h:form>
</f:view>
</html>
(
<%@ page contentType=
<%@ taglib uri=
<%@ taglib uri=
<html>
<head>
<title>
用戶注冊失敗
</title>
</head>
<body bgcolor=
<f:view>
<h:form id=
<h:graphicImage id=
url=
<h
<h:outputText id=
value=
<h:commandButton id=
value=
<p>
</h:form>
</f:view>
</html>
(
<?xml version=
<web
xmlns:xsi=
xsi:schemaLocation=
version=
<display
<context
<param
<param
</context
<listener>
<listener
</listener>
<servlet>
<display
<servlet
<servlet
<load
</servlet>
<servlet
<servlet
<url
</servlet
</web
(
<?xml version=
<!DOCTYPE beans PUBLIC
<beans>
<bean id=
class=
<property name=
<value>java:/MySqlDS</value>
</property>
</bean>
<bean id=
class=
<property name=
<ref local=
</property>
<property name=
<list>
<value>
com/openv/spring/service/hibernate/UserInfo
</value>
</list>
</property>
<property name=
<props>
<prop key=
net
</prop>
<prop key=
true
</prop>
</props>
</property>
</bean>
<bean id=
class=
<property name=
<ref local=
</property>
</bean>
<bean id=
class=
<property name=
<ref local=
</property>
</bean>
<bean id=
class=
<property name=
<ref local=
</property>
<property name=
<ref local=
</property>
<property name=
<props>
<prop key=
PROPAGATION_REQUIRED
</prop>
<prop key=
PROPAGATION_REQUIRED
</prop>
</props>
</property>
</bean>
<bean id=
class=
<property name=
<ref local=
</property>
</bean>
</beans>
(
<?xml version=
<!DOCTYPE faces
<faces
<application>
<locale
<default
</locale
</application>
<navigation
<description>
JSF Home Page
</description>
<from
<navigation
<description>
success
</description>
<from
<to
</navigation
<navigation
<description>
failure
</description>
<from
<to
</navigation
</navigation
<navigation
<description>
</description>
<from
<navigation
<description>
</description>
<from
<to
</navigation
</navigation
<navigation
<description>
</description>
<from
<navigation
<description>
</description>
<from
<to
</navigation
</navigation
<managed
<description>
InfoBean
</description>
<managed
<managed
com
</managed
<managed
<managed
<property
<property
<value>
</managed
<managed
<property
<property
<value>
</managed
</managed
</faces
From:http://tw.wingwit.com/Article/program/Java/ky/201311/27861.html