Mark, you are right about struts validation.
Please post your code.

Thanks
Deepak

-----Original Message-----
From: Galbreath, Mark [mailto:[EMAIL PROTECTED]]
Sent: Saturday, April 20, 2002 9:25 AM
To: 'Struts Users Mailing List'
Subject: RE: Validator help


I found using the Struts validation cumbersome and unpredictable, so I just
wrote a custom tag to validate my input forms.  If anyone is interested,
I'll post the code.

Mark

-----Original Message-----
From: Parmar, Dipakkumar [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 5:48 PM
To: Struts Users Mailing List
Subject: Validator help


Hi,

I'm having really hard time to figure out why the validator is not working.
Here is the summary what i did:

1. I tried to produce debug/error messages for org.apache.commons.validator
but no luck.
        (see thread "How can i turn on debug for
org.apache.commons.validator")

2. I override validate method in my ActionForm and put the same code from
validate method in validate.java(org.apache.commons.validator). I found out
that my validation.xml file is not initialize. I don't know why. I follow
validator sample come with struts. I'm using 1.1b1.

here is all required info if any one interested helping me out.

// CRTypeForm.java
public class CRTypeForm extends ValidatorForm {

    // CR Type name
    private String crTypeName;

    public String getCrTypeName() {
        logger.debug("CRTypeForm:getCrTypeName" + crTypeName);
        return crTypeName;
    }

    public void setCrTypeName(String crTypeName) {
        logger.debug("CRTypeForm:setCrTypeName" + crTypeName);
        this.crTypeName = crTypeName;
    }
}


// struts-config.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!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>

  <!-- ========== Form Bean Definitions
=================================== -->
  <form-beans>

    <!-- CR Type form bean -->
    <form-bean      name="CRTypeForm"
                    type="com.cgmp.esm.web.crtype.CRTypeForm"/>

  </form-beans>


  <!-- ========== Action Mapping Definitions
============================== -->
  <action-mappings>

    <!-- Save CR Type-->
    <action    path="/saveCrType"
               type="com.cgmp.esm.web.crtype.SaveCrTypeAction"
               name="CRTypeForm"
               scope="request"
               validate="true"
               input="/crtype.jsp">
       <forward name="success"              path="/success.jsp"/>
    </action>

  </action-mappings>

  <!-- ========== Message Resources Definitions
=========================== -->

  <message-resources
    parameter="com.cgmp.esm.web.ApplicationResources"/>

  <!-- ========== Plug Ins Configuration
================================== -->

  <!-- Add multiple validator resource files by setting the pathname
property -->
  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathname" value="/WEB-INF/validation.xml"/>
  </plug-in>

</struts-config>

# Validation.xml file
<form-validation>
   <formset>
      <form    name="CRTypeForm">
         <field    property="crTypeName"
                   depends="required, maxlength">
                     <arg0 key="prompt.crtypename"/>
                     <arg1 name="maxlength" key="${var:minlength}"
resource="false"/>
                     <var>
                       <var-name>maxlength</var-name>
                       <var-value>50</var-value>
                     </var>
         </field>
      </form>
   </formset>
</form-validation>

regards,
Deepak


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to