You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Mandel <Ma...@hds.com> on 2004/03/29 09:02:22 UTC

Validator doesn't pick up any errors?

Hey all,

First time posting to the list.

Been slowly learning Struts 1.1 over the past few weeks.

Trying to get the Validator working, to absolutely no avail.  I don't get
any Java Errors, and neither do I get any Validator errors.

I have <html:errors/> In my jsp page.

I am using an ActionForm that extends ValidatorActionForm.  I have tried
this class both without a validate(...) method, and with a validate(..)
method that called a super.validate.

I have debugged it out, and the validate(..) method on the
ValidatorActionForm returns null.  However, I have set both fields to be
required.

I'm totally stumped.

I'm hoping someone can see where I am going wrong.

(I've strippe out the XML and DTD declarations for the sake of brevity)

struts-config.xml
--
<struts-config>
  <form-beans>
    <form-bean name="security.login"
type="com.GSA.ActionForm.Security.Login" />
  </form-beans>
  <action-mappings>
    <action forward="tiles.page.login" path="/" />
    <action input="tiles.page.login" name="security.login"
path="/security/login" scope="request" type="com.GSA.Action.Security.Login">
      <forward name="Failure" path="tiles.page.login" />
    </action>
  </action-mappings>
  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
  </plug-in>
  <plug-in className="org.apache.struts.tiles.TilesPlugin">
    <set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
  </plug-in>
</struts-config>
--

validation.xml
--
<form-validation>
  <formset>
  	<form name="login">
       <field property="name" depends="required">
       	<arg0 name="required" key="security.login.name"/>
       </field>
       <field property="password" depends="required">
       	<arg0 name="required" key="security.login.password"/>
       </field>
    </form>
  </formset>
</form-validation>


--
Mark Mandel 
Web Application Developer 
Hitachi Data Systems Corporation 

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


Re: Validator doesn't pick up any errors?

Posted by Bill Siggelkow <bi...@bellsouth.net>.
Did you set "validate=true" for your action mappings?

Mark Mandel wrote:

> Hey all,
> 
> First time posting to the list.
> 
> Been slowly learning Struts 1.1 over the past few weeks.
> 
> Trying to get the Validator working, to absolutely no avail.  I don't get
> any Java Errors, and neither do I get any Validator errors.
> 
> I have <html:errors/> In my jsp page.
> 
> I am using an ActionForm that extends ValidatorActionForm.  I have tried
> this class both without a validate(...) method, and with a validate(..)
> method that called a super.validate.
> 
> I have debugged it out, and the validate(..) method on the
> ValidatorActionForm returns null.  However, I have set both fields to be
> required.
> 
> I'm totally stumped.
> 
> I'm hoping someone can see where I am going wrong.
> 
> (I've strippe out the XML and DTD declarations for the sake of brevity)
> 
> struts-config.xml
> --
> <struts-config>
>   <form-beans>
>     <form-bean name="security.login"
> type="com.GSA.ActionForm.Security.Login" />
>   </form-beans>
>   <action-mappings>
>     <action forward="tiles.page.login" path="/" />
>     <action input="tiles.page.login" name="security.login"
> path="/security/login" scope="request" type="com.GSA.Action.Security.Login">
>       <forward name="Failure" path="tiles.page.login" />
>     </action>
>   </action-mappings>
>   <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
>     <set-property property="pathnames"
> value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
>   </plug-in>
>   <plug-in className="org.apache.struts.tiles.TilesPlugin">
>     <set-property property="definitions-config"
> value="/WEB-INF/tiles-defs.xml" />
>   </plug-in>
> </struts-config>
> --
> 
> validation.xml
> --
> <form-validation>
>   <formset>
>   	<form name="login">
>        <field property="name" depends="required">
>        	<arg0 name="required" key="security.login.name"/>
>        </field>
>        <field property="password" depends="required">
>        	<arg0 name="required" key="security.login.password"/>
>        </field>
>     </form>
>   </formset>
> </form-validation>
> 
> 
> --
> Mark Mandel 
> Web Application Developer 
> Hitachi Data Systems Corporation 


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


Re: Validator doesn't pick up any errors?

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
ValidatorActionForm uses the path to find the corresponding validation form
rules. So for your "/security/login" action you need to name the form in
validation.xml to "security/login" instead of  "login".

If you use ValidatorForm instead it uses the form name  to find the
corresponding validation form rules.  So for your "/security/login" action
you need to name the form in validation.xml to "security.login" instead of
"login".

Both ValidatorForm  and ValidatorActionForm  have validate() method which
invokes the Validator framework. If you override these methods, then it
won't do any server side validation, unless you call super.validate().

Niall

----- Original Message ----- 
From: "Mark Mandel" <Ma...@hds.com>
To: <st...@jakarta.apache.org>
Sent: Monday, March 29, 2004 8:02 AM
Subject: Validator doesn't pick up any errors?


> Hey all,
>
> First time posting to the list.
>
> Been slowly learning Struts 1.1 over the past few weeks.
>
> Trying to get the Validator working, to absolutely no avail.  I don't get
> any Java Errors, and neither do I get any Validator errors.
>
> I have <html:errors/> In my jsp page.
>
> I am using an ActionForm that extends ValidatorActionForm.  I have tried
> this class both without a validate(...) method, and with a validate(..)
> method that called a super.validate.
>
> I have debugged it out, and the validate(..) method on the
> ValidatorActionForm returns null.  However, I have set both fields to be
> required.
>
> I'm totally stumped.
>
> I'm hoping someone can see where I am going wrong.
>
> (I've strippe out the XML and DTD declarations for the sake of brevity)
>
> struts-config.xml
> --
> <struts-config>
>   <form-beans>
>     <form-bean name="security.login"
> type="com.GSA.ActionForm.Security.Login" />
>   </form-beans>
>   <action-mappings>
>     <action forward="tiles.page.login" path="/" />
>     <action input="tiles.page.login" name="security.login"
> path="/security/login" scope="request"
type="com.GSA.Action.Security.Login">
>       <forward name="Failure" path="tiles.page.login" />
>     </action>
>   </action-mappings>
>   <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
>     <set-property property="pathnames"
> value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
>   </plug-in>
>   <plug-in className="org.apache.struts.tiles.TilesPlugin">
>     <set-property property="definitions-config"
> value="/WEB-INF/tiles-defs.xml" />
>   </plug-in>
> </struts-config>
> --
>
> validation.xml
> --
> <form-validation>
>   <formset>
>   <form name="login">
>        <field property="name" depends="required">
>        <arg0 name="required" key="security.login.name"/>
>        </field>
>        <field property="password" depends="required">
>        <arg0 name="required" key="security.login.password"/>
>        </field>
>     </form>
>   </formset>
> </form-validation>
>
>
> --
> Mark Mandel
> Web Application Developer
> Hitachi Data Systems Corporation
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



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