Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-28-2007, 03:59 PM
Senior Member
 
Join Date: Jun 2007
Posts: 119
Peter is on a distinguished road
DynaValidatorForm isn't working
Hi,

When I enter an invalid login the page doesn't display error messages.
These are my pages.



LOGIN.JSP

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> <html:html> <head> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> <META name="GENERATOR" content="IBM Software Development Platform"> <meta http-equiv="Content-Type" content="text/html;"> <title>Untitled</title> <style> TD{ font-family:verdana,arial; color:black; font-size:8pt; } .news{ font-family:arial; } .bot{ color:black; text-decoration:none; font-size:7pt; font-family:Verdana; font-weight:bold; } .copy{ font-size:7pt; color:black; } </style> </head> <body> <html:errors/> <html:form action="/submitLogin" > <table border="0" cellpadding="0" cellspacing="0" width="159"> <tr> <td valign="top" class="news"><b>UserName: </b></td> <td> <html:text property="userName" size="11" /> </td> </tr> <tr> <td valign="top" class="news"><b>PassWord: </b></td> <td> <html:text property="passWord" size="11" /> </td> </tr> <tr> <td valign="top"class="news"><INPUT type="submit" value="Logon"></td> </tr> </table> </html:form> </BODY> </html:html>
STRUTS_CONFIG.xml
Code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <!-- Data Sources --> <data-sources> </data-sources> <!-- Form Beans --> <form-beans> <form-bean name="LoginForm" type="org.apache.struts.validator.DynaValidatorForm"> <!-- Dynamic properties of the Login Form --> <form-property name="userName" type="java.lang.String" /> <form-property name="passWord" type="java.lang.String" /> </form-bean> </form-beans> <!-- Global Exceptions --> <global-exceptions> </global-exceptions> <!-- Global Forwards --> <global-forwards> </global-forwards> <!-- Action Mappings --> <action-mappings> <action path="/myPath" forward="/main.jsp" /> <action path="/submitLogin" scope="request" type="com.poshWebApp.actions.LoginAction" name="LoginForm" validate="false" input="/web/pages/login/login.jsp"> <forward name="success" path="/main.jsp" /> </action> </action-mappings> <!-- Message Resources --> <message-resources parameter="pbwebapp.resources.ApplicationResources"/> <!-- Validator Plugin --> <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml" /> </plug-in> </struts-config>

LOGINACTION.java
Code:
package com.poshWebApp.actions; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; /** * Form bean for a Struts application. * Users may access 2 fields on this form: * <ul> * <li>passWord - [your comment here] * <li>userName - [your comment here] * </ul> * @version 1.0 * @author */ public class LoginAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaValidatorForm dynaform = (DynaValidatorForm) form; request.setAttribute(mapping.getAttribute(), dynaform); System.out.println("Forwarding - SUCCESS page"); return mapping.findForward("success"); } }
Validation.xml
Code:
<formset> <form name="LoginForm"> <field property="userName" depends="required"> <arg0 key="prompt.username" /> </field> <field property="passWord" depends="required, minlength, maxlength"> <arg0 key="prompt.password" /> <arg1 key="${var:minlength}" name="minlength" resource="false" /> <arg2 key="${var:maxlength}" name="maxlength" resource="false" /> <var> <var-name>minlength</var-name> <var-value>6</var-value> </var> <var> <var-name>maxlength</var-name> <var-value>12</var-value> </var> </field> </form> </formset>
What's the problem?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-04-2007, 04:01 PM
Senior Member
 
Join Date: Jun 2007
Posts: 164
Heather is on a distinguished road
set validate="true" instead of validate="false"
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-04-2007, 04:02 PM
Senior Member
 
Join Date: Jun 2007
Posts: 130
Jack is on a distinguished road
try once :remove doctype in validation.xml
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-15-2008, 01:14 PM
Member
 
Join Date: Dec 2007
Posts: 19
JavaEmpires is on a distinguished road

Try this----

first of all make validate=true
write onsumit=" return validateLoginForm(this);" in your form tag
write <html:javascript formName="LoginForm" /> in your jsp before </html:form> tag

Having include above things, I think your form should work..

Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exceptions related to DynaValidatorForm rameshraj JavaServer Pages (JSP) and JSTL 1 12-27-2007 01:44 PM
Exceptions related to DynaValidatorForm rameshraj Java Servlet 0 12-26-2007 12:43 PM
keyListener isn't working for me lost_in_java AWT / Swing 5 07-07-2007 08:45 AM
working with servlets Freddie Java Servlet 2 05-15-2007 07:50 PM
Working With ANT JavaForums Eclipse 0 04-26-2007 10:16 PM


All times are GMT +3. The time now is 05:39 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org