Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
New User - Problems with Validation

New User - Problems with Validation

2007-12-02       - By GilbertW1

 Back

Hi,

I'm very new to struts 2 and I am trying to use it on a project I am
creating for one of my classes. The problem I am having is with the
validation framework. The validation I have setup seems to be functioning
correctly, except on the client it does not output the messages at all. It
prevents the action from being executed, but and returns to the jsp page,
but it does not display any messages. My code seems to be consistent with
the various tutorials I've read. Any help or suggestions would be greatly
appreciated, Here is the code for the jsp, validation.xml, and struts.xml
files. The action name is RegistrationAction.java and the file
RegistrationAction-validation.xml is placed in the same folder as the
action.

Register.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
   <title>Registration</title>
   <s:head theme="ajax" />
</head>
<h3>Registration</h3>
<body>
<s:form action="register" validate="true" namespace="/">
 <s:textfield label="User Name" name="username"/>
 <s:password label="Password" name="password" />
 <s:password label="Re-enter Password" name="passwordConf" />
 <s:textfield label="First Name" name="firstName" />
 <s:textfield label="Last Name" name="lastName" />
 <s:textfield label="E-mail Address" name="email" />
 <s:textfield label="Re-enter E-mail Address" name="emailConf" />
 <s:submit/>
 <s:reset/>
</s:form>
</body>
</html>


RegistrationAction-validation.xml

<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1 (See http://tor-1.ora-code.com).0.2.dtd">

<validators>
   <field name="username">
       <field-validator type="requiredstring">
           <message>You must enter a username.</message>
       </field-validator>
       <field-validator type="stringlength">
           8
           20
           true
           <message>Username must be between 8 and 20 characters.</message>
       </field-validator>
   </field>

   <field name="password">
       <field-validator type="requiredstring">
           <message>You must enter a password.</message>
       </field-validator>
       <field-validator type="stringlength">
           8
           20
           true
           <message>Password must be between 8 and 20 characters.</message>
       </field-validator>
       <field-validator type="fieldexpression">
           <![CDATA[password = passwordConf]]>
           <message>Password must be the same in both fields.</message>
       </field-validator>
   </field>

   <field name="firstName">
       <field-validator type="requiredstring">
           <message>You must enter your first name.</message>
       </field-validator>
       <field-validator type="regex">
           <![CDATA[(\w)* (@) (\w)* (.) (\w{2,3})]]>
       </field-validator>
   </field>

   <field name="lastName">
       <field-validator type="requiredstring">
           <message>You must enter your last name.</message>
       </field-validator>
       <field-validator type="regex">
           <![CDATA[([a-z] | [A-Z])*]]>
       </field-validator>
   </field>

   <field name="email">
       <field-validator type="requiredstring">
           <message>You must enter an email address.</message>
       </field-validator>
       <field-validator type="fieldexpression">
           <![CDATA[email = emailConf]]>
           <message>Email must be the same in both fields.</message>
       </field-validator>
       <field-validator type="regex">
           <![CDATA[([a-z] | [A-Z])*]]>
       </field-validator>
   </field>
</validators>


struts.xml

<?xml version="1.0" encoding="UTF-8 (See http://UTF-8.ora-code.com)"?>

<!DOCTYPE struts PUBLIC
   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
   "http://struts.apache.org/dtds/struts-2 (See http://uts-2.ora-code.com).0.dtd">

<struts>
   <package name="Actions" extends="struts-default" namespace="/">
       <action name="start" >
      <result>/jsp/Login.jsp</result>
    </action>
       <action name="login" class="com.BallyhOO.Actions.LoginAction">
           <result name="input">/jsp/Login.jsp</result>
           <result>/jsp/Home.jsp</result>
       </action>
       <action name="registration" >
           <result>/jsp/Register.jsp</result>
       </action>
       <action name="register"
class="com.BallyhOO.Actions.RegistrationAction">
           <result name="input">/jsp/Register.jsp</result>
           <result>/jsp/Home.jsp</result>
       </action>
       <action name="pageCreation" >
           <result>/jsp/CreatePage.jsp</result>
       </action>
       <action name="createPage"
class="com.BallyhOO.Actions.PageCreationAction">
           <result name="input">/jsp/CreatePage.jsp</result>
           <result>/jsp/PageSetup.jsp</result>
       </action>
       <action name="postCreation" >
           <result>/jsp/CreatePost.jsp</result>
       </action>
       <action name="createPost"
class="com.BallyhOO.Actions.PostCreationAction">
           <result name="input">/jsp/CreatePost.jsp</result>
           <result>/jsp/ViewPost.jsp</result>
       </action>
       <action name="pageSetup" >
           <result>/jsp/PageSetup.jsp</result>
       </action>
       <action name="setupPage"
class="com.BallyhOO.Actions.PageSetupAction">
           <result name="input">/jsp/PageSetup.jsp</result>
           <result>/jsp/ViewPage.jsp</result>
       </action>
   </package>
</struts>
--
View this message in context: http://www.nabble.com/New-User---Problems-with
-Validation-tf4934099.html#a14123138
Sent from the Struts - User mailing list archive at Nabble.com.


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)