You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Robert Taylor <64...@bellsouth.net> on 2005/05/10 11:34:24 UTC

datePatternStrict for MM/dd/yyyy seems to allow 04/04/200w

Greetings, I'm using Struts 1.2.7 and trying to validate a date field 
using the datePatternStrict with a date format of MM/dd/yyyy. Everything 
seems to work as expected until I enter a date like 04/04/200w. It seems 
that the date validation routine thinks that this is a valid date...or 
atleast it allows validation of the date field to pass. The docs say 
that date validation leverages SimpleDateFormat so I looked at the 
javadocs, but found nothing to indicate that parsing "04/04/200w" should 
pass (although I haven't tested it explicitely with just SimpleDateFormat).

I'm using the following snippet in my validation.xml file:
<var><var-name>datePatternStrict</var-name><var-value>MM/dd/yyyy</var-value></var>

BTW, the javascript for date validation seems to catch this, but the 
server side validation does not.

I must be doing something wrong or this must be a known issue.

Any ideas?

/robert


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


Re: datePatternStrict for MM/dd/yyyy seems to allow 04/04/200w

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
SimpleDateFormat does indeed parse this value as a valid date.

Niall

----- Original Message ----- 
From: "Robert Taylor" <64...@bellsouth.net>
Sent: Tuesday, May 10, 2005 10:34 AM


> Greetings, I'm using Struts 1.2.7 and trying to validate a date field
> using the datePatternStrict with a date format of MM/dd/yyyy. Everything
> seems to work as expected until I enter a date like 04/04/200w. It seems
> that the date validation routine thinks that this is a valid date...or
> atleast it allows validation of the date field to pass. The docs say
> that date validation leverages SimpleDateFormat so I looked at the
> javadocs, but found nothing to indicate that parsing "04/04/200w" should
> pass (although I haven't tested it explicitely with just
SimpleDateFormat).
>
> I'm using the following snippet in my validation.xml file:
>
<var><var-name>datePatternStrict</var-name><var-value>MM/dd/yyyy</var-value>
</var>
>
> BTW, the javascript for date validation seems to catch this, but the
> server side validation does not.
>
> I must be doing something wrong or this must be a known issue.



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


RE: ERROR: Server side validation using Validation framework

Posted by Arindam Samanta <Ar...@skytechsolutions.co.in>.

Thank you David. Yaa, I have done mistake with input attribute. It is 
working fine now.

Thanks,
Arindam




"David G. Friedman" <hu...@ix.netcom.com> 
05/11/2005 04:07 AM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>


To
"Struts Users Mailing List" <us...@struts.apache.org>
cc

Subject
RE: ERROR: Server side validation using Validation framework










Your input list "/login.jsp" but your other JSP's are listed under the 
/jsp
directory, SO, should your input be something different to get rid of the
page not found error BEFORE you mess with the Validator and claim it is 
the
source of all problems?

Instead of:
input="/login.jsp"

Is the file here (like your other examples for "Success" and Failure"):
input="/jsp/login.jsp"

Also, are you sure your action is forwarding to the "success" forward 
using
the correct CASE-sensitive spelling (i.e. "Success" not "success") ?

Regards,
David

-----Original Message-----
From: Arindam Samanta [mailto:Arindam.Samanta@skytechsolutions.co.in]
Sent: Tuesday, May 10, 2005 5:47 AM
To: Struts Users Mailing List
Subject: ERROR: Server side validation using Validation framework




Hi,

I am new in struts.  I am getting 'Page can not be displayed error when I
click on 'SAVE' button. validation is working fine when I implemented
client side validation to add following line
  <html:javascript staticJavascript="true" dynamicJavascript="true"
formName="loginForm"/>
But when I removed above code from jsp I faced page not found error but it
is not throwing any error into server. My Form class extends from
ValidatorForm.  My xml are,

 ********************struts-config.xml***********************
 <form-bean name="loginForm" type="com.ual.mars.form.LoginForm"/>
   <!-- ========== Action Mapping Definitions
============================== -->
  <action-mappings>
    <action
          path="/login"
          type="com.ual.mars.action.LoginAction"
          scope="request"
          name="loginForm"
          validate="true"
          input="/login.jsp">
          <forward name="Success" path="/jsp/employeedeatils.jsp"
redirect="true"/>
          <forward name="Failure" path="/jsp/loginform.jsp"
redirect="true"/>
    </action>

************************validation.xm*******************************
<form-validation>
<global>
<constant>
</constant>
</global>
  <formset>
  <form name="loginForm">
       <field
      property="userName"
      depends="required,mask">
      <arg0 key="userName.problem"/>
      <var>
        <var-name>mask</var-name>
        <var-value>^[a-zA-Z]*$</var-value>
      </var>
    </field>
     <field
          property="password"
          depends="required,mask">
          <arg0 key="password.problem"/>
          <var>
            <var-name>mask</var-name>
            <var-value>^[a-zA-Z]*$</var-value>
          </var>
    </field>
   </form>
  </formset>
</form-validation>

********************validator-rules.xml*******************
<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 bValid = true;
.....
....

*****************

Please help me.




Thanks,
Arindam


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


RE: ERROR: Server side validation using Validation framework

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
Your input list "/login.jsp" but your other JSP's are listed under the /jsp
directory, SO, should your input be something different to get rid of the
page not found error BEFORE you mess with the Validator and claim it is the
source of all problems?

Instead of:
input="/login.jsp"

Is the file here (like your other examples for "Success" and Failure"):
input="/jsp/login.jsp"

Also, are you sure your action is forwarding to the "success" forward using
the correct CASE-sensitive spelling (i.e. "Success" not "success") ?

Regards,
David

-----Original Message-----
From: Arindam Samanta [mailto:Arindam.Samanta@skytechsolutions.co.in]
Sent: Tuesday, May 10, 2005 5:47 AM
To: Struts Users Mailing List
Subject: ERROR: Server side validation using Validation framework




Hi,

I am new in struts.  I am getting 'Page can not be displayed error when I
click on 'SAVE' button. validation is working fine when I implemented
client side validation to add following line
  <html:javascript staticJavascript="true" dynamicJavascript="true"
formName="loginForm"/>
But when I removed above code from jsp I faced page not found error but it
is not throwing any error into server. My Form class extends from
ValidatorForm.  My xml are,

 ********************struts-config.xml***********************
 <form-bean name="loginForm" type="com.ual.mars.form.LoginForm"/>
   <!-- ========== Action Mapping Definitions
============================== -->
  <action-mappings>
    <action
          path="/login"
          type="com.ual.mars.action.LoginAction"
          scope="request"
          name="loginForm"
          validate="true"
          input="/login.jsp">
          <forward name="Success" path="/jsp/employeedeatils.jsp"
redirect="true"/>
          <forward name="Failure" path="/jsp/loginform.jsp"
redirect="true"/>
    </action>

************************validation.xm*******************************
<form-validation>
<global>
<constant>
</constant>
</global>
  <formset>
  <form name="loginForm">
       <field
      property="userName"
      depends="required,mask">
      <arg0 key="userName.problem"/>
      <var>
        <var-name>mask</var-name>
        <var-value>^[a-zA-Z]*$</var-value>
      </var>
    </field>
     <field
          property="password"
          depends="required,mask">
          <arg0 key="password.problem"/>
          <var>
            <var-name>mask</var-name>
            <var-value>^[a-zA-Z]*$</var-value>
          </var>
    </field>
   </form>
  </formset>
</form-validation>

********************validator-rules.xml*******************
<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 bValid = true;
.....
....

*****************

Please help me.




Thanks,
Arindam


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


ERROR: Server side validation using Validation framework

Posted by Arindam Samanta <Ar...@skytechsolutions.co.in>.

Hi,

I am new in struts.  I am getting 'Page can not be displayed error when I 
click on 'SAVE' button. validation is working fine when I implemented 
client side validation to add following line 
  <html:javascript staticJavascript="true" dynamicJavascript="true" 
formName="loginForm"/>
But when I removed above code from jsp I faced page not found error but it 
is not throwing any error into server. My Form class extends from 
ValidatorForm.  My xml are,

 ********************struts-config.xml***********************
 <form-bean name="loginForm" type="com.ual.mars.form.LoginForm"/>
   <!-- ========== Action Mapping Definitions 
============================== -->
  <action-mappings> 
    <action
          path="/login"
          type="com.ual.mars.action.LoginAction"
          scope="request"
          name="loginForm"
          validate="true"
          input="/login.jsp">
          <forward name="Success" path="/jsp/employeedeatils.jsp" 
redirect="true"/>
          <forward name="Failure" path="/jsp/loginform.jsp" 
redirect="true"/>
    </action> 

************************validation.xm*******************************
<form-validation>
<global>
<constant>
</constant>
</global>
  <formset> 
  <form name="loginForm">
       <field 
      property="userName"
      depends="required,mask">
      <arg0 key="userName.problem"/> 
      <var>
        <var-name>mask</var-name>
        <var-value>^[a-zA-Z]*$</var-value>
      </var> 
    </field>
     <field 
          property="password"
          depends="required,mask">
          <arg0 key="password.problem"/> 
          <var>
            <var-name>mask</var-name>
            <var-value>^[a-zA-Z]*$</var-value>
          </var> 
    </field>
   </form> 
  </formset> 
</form-validation>

********************validator-rules.xml*******************
<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 bValid = true;
..... 
....

*****************

Please help me.




Thanks,
Arindam