You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by leo mj <le...@yahoo.com> on 2006/09/07 12:59:06 UTC

Field check using DynaValidatorForm

hi all,

  I want to do Dynamic field check using validator framework.

I have done the following steps:

1.Add validator plugin in struts-config.xml

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
   <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
   </plug-in>

2.I have used index.jsp as my LOGIN page.

With the following 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 http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet"
    type="text/css">
<TITLE></TITLE>
</HEAD>

<BODY>
<html:errors/>
<html:form action="/submitLogin.do">
    <TABLE border="0" cellpadding="0" cellspacing="0">
        <TBODY>
            <TR>
                <TD></TD>
                <TD></TD>
                <TD></TD>
                <TD></TD>
                <TD width="28"></TD>
                <TD width="54"></TD>
                <TD width="68"></TD>
                <TD width="77"></TD>
                <TD width="89"></TD>
                <TD width="59"></TD>
            </TR>
            <TR>
                <TD height="2"></TD>
                <TD height="2"></TD>
                <TD height="2"></TD>
                <TD height="2"></TD>
                <TD width="28" height="2"></TD>
                <TD width="54" height="2"></TD>
                <TD width="68" height="2"></TD>
                <TD width="77" height="2"></TD>
                <TD width="89" height="2"></TD>
                <TD width="59" height="2"></TD>
            </TR>
            <TR>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD width="28" height="20"></TD>
                <TD width="54" height="20"></TD>
                <TD width="68" height="20"></TD>
                <TD width="77" height="20"></TD>
                <TD width="89" height="20"></TD>
                <TD width="59" height="20"></TD>
            </TR>
            <TR>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD width="28" height="38"></TD>
                <TD width="54" height="38"></TD>
                <TD width="68" height="38"></TD>
                <TD width="77" height="38"></TD>
                <TD width="89" height="38"></TD>
                <TD width="59" height="38"></TD>
            </TR>
            <TR>
                <TD></TD>
                <TD></TD>
                <TD></TD>
                <TD></TD>
                <TD width="28"></TD>
                <TD width="54"></TD>
                <TD width="68">Name</TD>
                <TD width="77"><html:text property="username"></html:text></TD>
                <TD width="89"></TD>
                <TD width="59"></TD>
            </TR>
            <TR>
                <TD height="65"></TD>
                <TD height="65"></TD>
                <TD height="65"></TD>
                <TD height="65"></TD>
                <TD width="28" height="65"></TD>
                <TD width="54" height="65"></TD>
                <TD width="68" height="65">Password</TD>
                <TD width="77" height="65"><html:password property="password"></html:password></TD>
                <TD width="89" height="65"></TD>
                <TD width="59" height="65"></TD>
            </TR>
            <TR>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD width="28" height="20"></TD>
                <TD width="54" height="20"></TD>
                <TD width="68" height="20"></TD>
                <TD width="77" height="20"></TD>
                <TD width="89" height="20"></TD>
                <TD width="59" height="20"></TD>
            </TR>
            <TR>
                <TD height="31"></TD>
                <TD height="31"></TD>
                <TD height="31"></TD>
                <TD height="31"></TD>
                <TD height="31" width="28"></TD>
                <TD height="31" width="54"></TD>
                <TD height="31" width="68"></TD>
                <TD height="31" width="77"></TD>
                <TD height="31" width="89"><html:submit value="Submit"></html:submit></TD>
                <TD height="31" width="59"></TD>
            </TR>
            <TR>
                <TD height="37"></TD>
                <TD height="37"></TD>
                <TD height="37"></TD>
                <TD height="37"></TD>
                <TD height="37" width="28"></TD>
                <TD height="37" width="54"></TD>
                <TD height="37" width="68"></TD>
                <TD height="37" width="77"></TD>
                <TD height="37" width="89"></TD>
                <TD height="37" width="59"></TD>
            </TR>
            <TR>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD height="38" width="28"></TD>
                <TD height="38" width="54"></TD>
                <TD height="38" width="68"></TD>
                <TD height="38" width="77"></TD>
                <TD height="38" width="89"></TD>
                <TD height="38" width="59"></TD>
            </TR>
        </TBODY>
    </TABLE>
</html:form>
</BODY>
</html:html>

3.Now I have added submitLogin action in the struts-config.xml file 

<action-mappings>
    <action path="/submitLogin" scope="request" type="com.ibm.dynamicform.resources.LoginAction" 
    name="LoginForm" validate="false" input="/index.jsp">
    <forward name="success" path="/done.jsp"></forward>
    </action>

4.Now the LoginAction Action class is like this

package com.ibm.dynamicform.resources;


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;


public class LoginAction extends Action {

public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
    
    ActionForward forward=new ActionForward();
    DynaValidatorForm dynaform = (DynaValidatorForm) form;
    String username=(String)dynaform.get("username");
    String password=(String)dynaform.get("password");
    
    if(username.equalsIgnoreCase("")||(password.equalsIgnoreCase(""))){
        System.out.println("null username");
        forward=mapping.getInputForward();    
    }
    else{
        System.out.println(username+":"+password);
        forward=mapping.findForward("success");    
    }
    
    
    return forward;
    

}


}


5.My validation.xml looks like
<!DOCTYPE form-validation 
PUBLIC "-//Apache Software Foundation//
       DTD Commons Validator Rules
       Configuration 1.0//EN"
       "http://jakarta.apache.org/
      commons/dtds/validator_1_0.dtd">


<form-validation>
  <formset>
    <form name="LogonForm">
      <field property="username"
            depends="required">
       <arg0 key="prompt.username"/> 
      </field>
      <field property="password"
            depends="required">
        <arg0 key="prompt.password"/>
      </field>
    </form>
  </formset>
</form-validation>

6.My validator-rules.xml looks like

<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons
           Validator Rules Configuration 1.0//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">

<form-validation>
  <global>
    <validator name="required"
          classname="org.apache.struts.validator.FieldChecks"
             method="validateRequired"
       methodParams="java.lang.Object,
                     org.apache.commons.validator.ValidatorAction,
                     org.apache.commons.validator.Field,
                     org.apache.struts.action.ActionErrors,
                     javax.servlet.http.HttpServletRequest"
                msg="errors.required">
      <javascript>
        <![CDATA[
        function validateRequired(form) {
          var isValid = true;
          var focusField = null;
          var i = 0;
          var fields = new Array();
          oRequired = new required();
          for (x in oRequired) {
            var field = form[oRequired[x][0]];

            if (field.type == 'text' ||
                field.type == 'textarea' ||
                field.type == 'file' ||
                field.type == 'select-one' ||
                field.type == 'radio' ||
                field.type == 'password') {

              var value = '';

              // get field's value
              if (field.type == "select-one") {
                var si = field.selectedIndex;
                if (si >= 0) {
                  value = field.options[si].value;
                }
              } else {
                value = field.value;
              }

              if (trim(value).length == 0) { {
                if (i == 0) {
                  focusField = field;
                }
                fields[i++] = oRequired[x][1];
                isValid = false;
              }
            }
          }

          if (fields.length > 0) {
            focusField.focus();
            alert(fields.join('\n'));
          }

          return isValid;
        }

        // Trim whitespace from left and right sides of s.
        function trim(s) {
          return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
        }

        ]]>
      </javascript>
    </validator>
  </global>
</form-validation>

My web app is able to handle the login actions but no error is displayed in the index.jsp when i submit the form without username and password.

Please help me why I am getting this situation..
Also my ApplicationResources.properties looks like this
.....
# Optional header and footer for <errors/> tag.
#errors.header=<ul>
#errors.footer=</ul>
# Error messages for Validator framework validations
errors.required={0} is required.
errors.minlength={0} cannot be less than {1} characters.
errors.maxlength={0} cannot be greater than {2} characters.
errors.invalid={0} is invalid.
errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.0.   errors.float={0} must be a float.
errors.double={0} must be a double.
errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is not a valid credit card number.
errors.email={0} is an invalid e-mail address.

#ERROR KEYS

prompt.username=Username
prompt.password=Password
NOTE:i hve used <html:errors/> in my index.jsp where i am expecting the error to be displayed.


Warm Regards,
Atul 

 		
---------------------------------
 All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.

RE: Field check using DynaValidatorForm

Posted by David Friedman <hu...@ix.netcom.com>.
>From the note about the MalFormURL Exception I would initially guess you
started the header DOCTYPE in the file incorrectly.  You gave a 6 line entry
from your validation.xml file split like so:

<!DOCTYPE form-validation
PUBLIC "-//Apache Software Foundation//
       DTD Commons Validator Rules
       Configuration 1.0//EN"
       "http://jakarta.apache.org/
      commons/dtds/validator_1_0.dtd">

In a DOCTYPE you should NEVER break up any quoted sections.  You should
either have one, two or three lines when you keep the quoted sections
together, not 6 lines.  The same goes for your validator-rules.xml file.  In
fact the validator-rules file should never be modified but be taken directly
from the struts distribution so its DOCTYPE line would not be split
incorrectly.  Would you be able to use a url like this in your browser with
a space in it? Not like this (which is much like how the SAX parser reads
it:

"http://jakarta.apache.org/ commons/dtds/validator_1_0.dtd"

It looks like you took your inaccurate entries from the 2004 Oracle article:
http://www.oracle.com/technology/oramag/oracle/04-jan/o14dev_struts.html

Once you have fixed this problem you will have at least ONE more issue.  You
made a typo (or copied your information into your email correctly) with the
form name.  You defined your mapping with 'name="LoginForm"'.  Your
validation.xml file lists it differently as "LogonForm".  If those two don't
match each other and your form-bean name="LoginForm" attribute (which didn't
appear in your 2nd to last email), then the validator will not match and
fail.  Not to mention you'll get errors because the bean cannot be found if
it not spelled "LoginForm" in your form-bean definition to match your
action's name attribute.

Regards,
David


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Field check using DynaValidatorForm

Posted by leo mj <le...@yahoo.com>.
adam,

Thanks...

I have changed the validate="true" but i am getting an exception at the 
<plug-in> part of struts-config.xml

The exception is
ValidatorPlug I org.apache.struts.validator.ValidatorPlugIn initResources Loading validation rules file from '/WEB-INF/validator-rules.xml'
[9/7/06 17:35:15:422 IST] 00000021 ValidatorPlug I org.apache.struts.validator.ValidatorPlugIn initResources Loading validation rules file from '/WEB-INF/validation.xml'

ValidatorPlug E org.apache.struts.validator.ValidatorPlugIn initResources Illegal character in URL    java.net.MalformedURLException: Illegal character in URL

So even before running the App i am getting this exception....

I am using RAD..and added struts cpabilities in my Dynamic Project.But validation.xml and validator-rules.xml wasn't created so I added both the files
manually.

With warm regards,
leo


"Samere, Adam J" <as...@paychex.com> wrote: You have validate="false" in your action mapping. Change that to true.

Adam 

-----Original Message-----
From: leo mj [mailto:leomj2005@yahoo.com] 
Sent: Thursday, September 07, 2006 6:59 AM
To: user@struts.apache.org
Subject: Field check using DynaValidatorForm

hi all,

  I want to do Dynamic field check using validator framework.

I have done the following steps:

1.Add validator plugin in struts-config.xml



   
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
   

2.I have used index.jsp as my LOGIN page.

With the following code:


 <%@
taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> <%@ taglib
uri="/WEB-INF/struts-bean.tld" prefix="bean"%>   <%@
page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>


 

href="theme/Master.css" rel="stylesheet"
    type="text/css">






    

        
            
                

                

                

                

                

                

                

                

                

                

            
            
                

                

                

                

                

                

                

                

                

                

            
            
                

                

                

                

                

                

                

                

                

                

            
            
                

                

                

                

                

                

                

                

                

                

            
            
                

                

                

                

                

                

                Name
                
property="username">
                

                

            
            
                

                

                

                

                

                

                Password
                
property="password">
                

                

            
            
                

                

                

                

                

                

                

                

                

                

            
            
                

                

                

                

                

                

                

                

                
value="Submit">
                

            
            
                

                

                

                

                

                

                

                

                

                

            
            
                

                

                

                

                

                

                

                

                

                

            
        
    




3.Now I have added submitLogin action in the struts-config.xml file 


    
type="com.ibm.dynamicform.resources.LoginAction" 
    name="LoginForm" validate="false" input="/index.jsp">
    
    

4.Now the LoginAction Action class is like this

package com.ibm.dynamicform.resources;


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;


public class LoginAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception {
    
    ActionForward forward=new ActionForward();
    DynaValidatorForm dynaform = (DynaValidatorForm) form;
    String username=(String)dynaform.get("username");
    String password=(String)dynaform.get("password");
    
    if(username.equalsIgnoreCase("")||(password.equalsIgnoreCase(""))){
        System.out.println("null username");
        forward=mapping.getInputForward();    
    }
    else{
        System.out.println(username+":"+password);
        forward=mapping.findForward("success");    
    }
    
    
    return forward;
    

}


}


5.My validation.xml looks like

PUBLIC "-//Apache Software Foundation//
       DTD Commons Validator Rules
       Configuration 1.0//EN"
       "http://jakarta.apache.org/
      commons/dtds/validator_1_0.dtd">



  
    
      
            depends="required">
        
      
      
            depends="required">
        
      
    
  


6.My validator-rules.xml looks like


          "-//Apache Software Foundation//DTD Commons
           Validator Rules Configuration 1.0//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">


  
    
          classname="org.apache.struts.validator.FieldChecks"
             method="validateRequired"
       methodParams="java.lang.Object,
                     org.apache.commons.validator.ValidatorAction,
                     org.apache.commons.validator.Field,
                     org.apache.struts.action.ActionErrors,
                     javax.servlet.http.HttpServletRequest"
                msg="errors.required">
      
                function validateRequired(form) {
          var isValid = true;
          var focusField = null;
          var i = 0;
          var fields = new Array();
          oRequired = new required();
          for (x in oRequired) {
            var field = form[oRequired[x]-->
            if (field.type == 'text' ||
                field.type == 'textarea' ||
                field.type == 'file' ||
                field.type == 'select-one' ||
                field.type == 'radio' ||
                field.type == 'password') {

              var value = '';

              // get field's value
              if (field.type == "select-one") {
                var si = field.selectedIndex;
                if (si >= 0) {
                  value = field.options[si].value;
                }
              } else {
                value = field.value;
              }

              if (trim(value).length == 0) { {
                if (i == 0) {
                  focusField = field;
                }
                fields[i++] = oRequired[x][1];
                isValid = false;
              }
            }
          }

          if (fields.length > 0) {
            focusField.focus();
            alert(fields.join('\n'));
          }

          return isValid;
        }

        // Trim whitespace from left and right sides of s.
        function trim(s) {
          return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
        }

        ]]>
      
    
  


My web app is able to handle the login actions but no error is displayed
in the index.jsp when i submit the form without username and password.

Please help me why I am getting this situation..
Also my ApplicationResources.properties looks like this
......
# Optional header and footer for  tag.
#errors.header=
#errors.footer=

# Error messages for Validator framework validations
errors.required={0} is required.
errors.minlength={0} cannot be less than {1} characters.
errors.maxlength={0} cannot be greater than {2} characters.
errors.invalid={0} is invalid.
errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.0.   errors.float={0} must be a float.
errors.double={0} must be a double.
errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is not a valid credit card number.
errors.email={0} is an invalid e-mail address.

#ERROR KEYS

prompt.username=Username
prompt.password=Password
NOTE:i hve used  in my index.jsp where i am expecting the
error to be displayed.


Warm Regards,
Atul 

   
---------------------------------
 All-new Yahoo! Mail - Fire up a more powerful email and get things done
faster.

-----------------------------------------
The information contained in this message may be privileged,
confidential, and protected from disclosure. If the reader of this
message is not the intended recipient, or any employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution, or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.

Thank you. Paychex, Inc.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



 		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.

RE: Field check using DynaValidatorForm

Posted by "Samere, Adam J" <as...@paychex.com>.
You have validate="false" in your action mapping. Change that to true.

Adam 

-----Original Message-----
From: leo mj [mailto:leomj2005@yahoo.com] 
Sent: Thursday, September 07, 2006 6:59 AM
To: user@struts.apache.org
Subject: Field check using DynaValidatorForm

hi all,

  I want to do Dynamic field check using validator framework.

I have done the following steps:

1.Add validator plugin in struts-config.xml

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
   <set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
   </plug-in>

2.I have used index.jsp as my LOGIN page.

With the following 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 http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<META http-equiv="Content-Style-Type" content="text/css"> <LINK
href="theme/Master.css" rel="stylesheet"
    type="text/css">
<TITLE></TITLE>
</HEAD>

<BODY>
<html:errors/>
<html:form action="/submitLogin.do">
    <TABLE border="0" cellpadding="0" cellspacing="0">
        <TBODY>
            <TR>
                <TD></TD>
                <TD></TD>
                <TD></TD>
                <TD></TD>
                <TD width="28"></TD>
                <TD width="54"></TD>
                <TD width="68"></TD>
                <TD width="77"></TD>
                <TD width="89"></TD>
                <TD width="59"></TD>
            </TR>
            <TR>
                <TD height="2"></TD>
                <TD height="2"></TD>
                <TD height="2"></TD>
                <TD height="2"></TD>
                <TD width="28" height="2"></TD>
                <TD width="54" height="2"></TD>
                <TD width="68" height="2"></TD>
                <TD width="77" height="2"></TD>
                <TD width="89" height="2"></TD>
                <TD width="59" height="2"></TD>
            </TR>
            <TR>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD width="28" height="20"></TD>
                <TD width="54" height="20"></TD>
                <TD width="68" height="20"></TD>
                <TD width="77" height="20"></TD>
                <TD width="89" height="20"></TD>
                <TD width="59" height="20"></TD>
            </TR>
            <TR>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD width="28" height="38"></TD>
                <TD width="54" height="38"></TD>
                <TD width="68" height="38"></TD>
                <TD width="77" height="38"></TD>
                <TD width="89" height="38"></TD>
                <TD width="59" height="38"></TD>
            </TR>
            <TR>
                <TD></TD>
                <TD></TD>
                <TD></TD>
                <TD></TD>
                <TD width="28"></TD>
                <TD width="54"></TD>
                <TD width="68">Name</TD>
                <TD width="77"><html:text
property="username"></html:text></TD>
                <TD width="89"></TD>
                <TD width="59"></TD>
            </TR>
            <TR>
                <TD height="65"></TD>
                <TD height="65"></TD>
                <TD height="65"></TD>
                <TD height="65"></TD>
                <TD width="28" height="65"></TD>
                <TD width="54" height="65"></TD>
                <TD width="68" height="65">Password</TD>
                <TD width="77" height="65"><html:password
property="password"></html:password></TD>
                <TD width="89" height="65"></TD>
                <TD width="59" height="65"></TD>
            </TR>
            <TR>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD height="20"></TD>
                <TD width="28" height="20"></TD>
                <TD width="54" height="20"></TD>
                <TD width="68" height="20"></TD>
                <TD width="77" height="20"></TD>
                <TD width="89" height="20"></TD>
                <TD width="59" height="20"></TD>
            </TR>
            <TR>
                <TD height="31"></TD>
                <TD height="31"></TD>
                <TD height="31"></TD>
                <TD height="31"></TD>
                <TD height="31" width="28"></TD>
                <TD height="31" width="54"></TD>
                <TD height="31" width="68"></TD>
                <TD height="31" width="77"></TD>
                <TD height="31" width="89"><html:submit
value="Submit"></html:submit></TD>
                <TD height="31" width="59"></TD>
            </TR>
            <TR>
                <TD height="37"></TD>
                <TD height="37"></TD>
                <TD height="37"></TD>
                <TD height="37"></TD>
                <TD height="37" width="28"></TD>
                <TD height="37" width="54"></TD>
                <TD height="37" width="68"></TD>
                <TD height="37" width="77"></TD>
                <TD height="37" width="89"></TD>
                <TD height="37" width="59"></TD>
            </TR>
            <TR>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD height="38"></TD>
                <TD height="38" width="28"></TD>
                <TD height="38" width="54"></TD>
                <TD height="38" width="68"></TD>
                <TD height="38" width="77"></TD>
                <TD height="38" width="89"></TD>
                <TD height="38" width="59"></TD>
            </TR>
        </TBODY>
    </TABLE>
</html:form>
</BODY>
</html:html>

3.Now I have added submitLogin action in the struts-config.xml file 

<action-mappings>
    <action path="/submitLogin" scope="request"
type="com.ibm.dynamicform.resources.LoginAction" 
    name="LoginForm" validate="false" input="/index.jsp">
    <forward name="success" path="/done.jsp"></forward>
    </action>

4.Now the LoginAction Action class is like this

package com.ibm.dynamicform.resources;


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;


public class LoginAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception {
    
    ActionForward forward=new ActionForward();
    DynaValidatorForm dynaform = (DynaValidatorForm) form;
    String username=(String)dynaform.get("username");
    String password=(String)dynaform.get("password");
    
    if(username.equalsIgnoreCase("")||(password.equalsIgnoreCase(""))){
        System.out.println("null username");
        forward=mapping.getInputForward();    
    }
    else{
        System.out.println(username+":"+password);
        forward=mapping.findForward("success");    
    }
    
    
    return forward;
    

}


}


5.My validation.xml looks like
<!DOCTYPE form-validation
PUBLIC "-//Apache Software Foundation//
       DTD Commons Validator Rules
       Configuration 1.0//EN"
       "http://jakarta.apache.org/
      commons/dtds/validator_1_0.dtd">


<form-validation>
  <formset>
    <form name="LogonForm">
      <field property="username"
            depends="required">
       <arg0 key="prompt.username"/> 
      </field>
      <field property="password"
            depends="required">
        <arg0 key="prompt.password"/>
      </field>
    </form>
  </formset>
</form-validation>

6.My validator-rules.xml looks like

<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons
           Validator Rules Configuration 1.0//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">

<form-validation>
  <global>
    <validator name="required"
          classname="org.apache.struts.validator.FieldChecks"
             method="validateRequired"
       methodParams="java.lang.Object,
                     org.apache.commons.validator.ValidatorAction,
                     org.apache.commons.validator.Field,
                     org.apache.struts.action.ActionErrors,
                     javax.servlet.http.HttpServletRequest"
                msg="errors.required">
      <javascript>
        <![CDATA[
        function validateRequired(form) {
          var isValid = true;
          var focusField = null;
          var i = 0;
          var fields = new Array();
          oRequired = new required();
          for (x in oRequired) {
            var field = form[oRequired[x][0]];

            if (field.type == 'text' ||
                field.type == 'textarea' ||
                field.type == 'file' ||
                field.type == 'select-one' ||
                field.type == 'radio' ||
                field.type == 'password') {

              var value = '';

              // get field's value
              if (field.type == "select-one") {
                var si = field.selectedIndex;
                if (si >= 0) {
                  value = field.options[si].value;
                }
              } else {
                value = field.value;
              }

              if (trim(value).length == 0) { {
                if (i == 0) {
                  focusField = field;
                }
                fields[i++] = oRequired[x][1];
                isValid = false;
              }
            }
          }

          if (fields.length > 0) {
            focusField.focus();
            alert(fields.join('\n'));
          }

          return isValid;
        }

        // Trim whitespace from left and right sides of s.
        function trim(s) {
          return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
        }

        ]]>
      </javascript>
    </validator>
  </global>
</form-validation>

My web app is able to handle the login actions but no error is displayed
in the index.jsp when i submit the form without username and password.

Please help me why I am getting this situation..
Also my ApplicationResources.properties looks like this
......
# Optional header and footer for <errors/> tag.
#errors.header=<ul>
#errors.footer=</ul>
# Error messages for Validator framework validations
errors.required={0} is required.
errors.minlength={0} cannot be less than {1} characters.
errors.maxlength={0} cannot be greater than {2} characters.
errors.invalid={0} is invalid.
errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.0.   errors.float={0} must be a float.
errors.double={0} must be a double.
errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is not a valid credit card number.
errors.email={0} is an invalid e-mail address.

#ERROR KEYS

prompt.username=Username
prompt.password=Password
NOTE:i hve used <html:errors/> in my index.jsp where i am expecting the
error to be displayed.


Warm Regards,
Atul 

 		
---------------------------------
 All-new Yahoo! Mail - Fire up a more powerful email and get things done
faster.

-----------------------------------------
The information contained in this message may be privileged,
confidential, and protected from disclosure. If the reader of this
message is not the intended recipient, or any employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution, or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.

Thank you. Paychex, Inc.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org