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" <[EMAIL PROTECTED]> wrote: You have validate="false" in your 
action mapping. Change that to true.

Adam 

-----Original Message-----
From: leo mj [mailto:[EMAIL PROTECTED] 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



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

Reply via email to