Magazine
 
Integrating JSF, Spring and Hibernate
 

registration.jsp : This is the code for above page. The backing bean used for this page is “Bean”. When the page is submitted then register() method is called which checks the user name entered by the user. If the name is
already registered then user is informed that the user with name is already registered otherwise a new user object is created and all the fields related with the user is added in that object i.e. user name, password, email,
address. Before checking the user existencevalidateData() method is called to check all
the fields. If anything doesn’t match with the requirement then the same page is again presented to the user with the validation messages. The messages can be customized creating the MessageFactory class in which
messages from the resource bundle for the specific locale are picked and shown in the page. You can see the code for bean below in the tutorial.

<%@ taglib uri=”http://java.sun.com/jsf/
html” prefix=”h”%>
<%@ taglib uri=”http://java.sun.com/jsf/
core” prefix=”f”%>
<%@ taglib uri=”http://myfaces.apache.org/
tomahawk” prefix=”t”%>
<f:loadBundle
basename=”net.roseindia.web.ui.messages”
var=”message”/>
<f:view>
<html>
<meta http-equiv=”Content-Type”
content=”text/html; charset=iso-8859-1">
<head>
<title>Registration</title>
<link href=”mycss.css” rel=”stylesheet”
type=”text/css”/>
</head>
<body ><center>
<h:form id=”registerForm”>
<h:panelGrid width=”100%” columns=”1"
border=”0" style=”padding-left:10px;
padding-top:10px; “
styleClass=”top_bg”>
<h:dataTable id=”dt1" border=”0"
cellpadding=”0" cellspacing=”0" var=”ab”>
<h:column>
<f:facet name=”header”>

 

<h:outputText value=”RoseIndia”
styleClass=”style4"/>
</f:facet>
</h:column>
</h:dataTable>
</h:panelGrid>
<h:panelGrid width=”175px”
columns=”3" border=”0" cellspacing=”0"
cellpadding=”0">
<h:outputText value=” “/>
<h:graphicImage id=”gi3"
value=”images/verticle_line.gif”
width=”4" height=”18"></h:graphicImage>
<h:panelGroup>
<h:dataTable id=”dt2" border=”0"
cellpadding=”0" cellspacing=”0" width=”250"
var=”gh”>
<h:column>
<f:facet name=”header”>
<h:outputText value=”User Registration “
styleClass=”style1"/>
</f:facet>
</h:column>
</h:dataTable>
</h:panelGroup>
<h:graphicImage id=”gi4" value=”images/
horizontal_line.gif” width=”25" height=”4" >
</h:graphicImage>
<h:graphicImage id=”gi8" value=”images/
horizontal_line.gif” width=”5" height=”4" ></
h:graphicImage>
<h:graphicImage id=”gi6" value=”images/
horizontal_line.gif” width=”260" height=”4" >
</h:graphicImage>
<h:outputText value=” “/>
<h:graphicImage id=”gi7" value=”images/
verticle_line.gif” width=”5" height=”100%” >
</h:graphicImage>
<h:panelGroup>
<h:dataTable id=”dt3" border=”0"
cellpadding=”0" cellspacing=”0" width=”250"
var=”gh”>
<h:column>
<f:facet name=”header”>
<h:outputText
value=”#{message.already_registered_msg}”
style=”color:red; font-weight: bold;”
rendered=”#{Bean.exist}”/>
</f:facet>
</h:column>
</h:dataTable>
<h:panelGrid width=”100px” columns=”2"

Jan 2008 | Java Jazz Up |62
previous
index
next
 
 
View All Topics
All Pages of this Issue
Pages: 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, 89 , 90 , 91 , 92 , 93 , 94 , 95 , 96 , 97 , 98 , 99 , 100 , 101 , 102 , 103, 104 , 105 ,

106, 107,

Download PDF