You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeremy Jardin <je...@gmail.com> on 2006/07/20 12:05:22 UTC

pb using validator it does not work !

Hi,

I'm trying to use validator plugin in my application, and it does not work
at all !

First, I've just add <html:errors/> in my jsp.

I've written a basic validation.xml file like this :
<form name="StartSubscriptionForm">
    <field property="name" depends="required">
        <arg0 key="inscription.nom"/>
    </field>
</form>

Then, I've also a classic validation-rules.xml file, with usefull rules.
Thoses files are un my WEB-INF directory.

I added in my struts-config.xml fil those lines :

   <form-beans>
  <form-bean name="StartSubscriptionForm" type="
sapinscription.form.StartSubscriptionForm"/>

    </form-beans>

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

    <action    path      = "/StartSubscription"
               type      = "sapinscription.action.StartSubscriptionAction"
               name      = "StartSubscriptionForm"
               scope     = "session"
               validate  = "true"
               input     = "/jsp/inscriptionForm.jsp"
      >
        <forward name="subscribingPage" path="/jsp/inscriptionForm.jsp" />
     </action>

    </action-mappings>

  <message-resources null="false" parameter="conf.WebMessages"/>

 <!-- ============== Validator plugin
======================================-->

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


It seems to be all right.. but when I submit my form, Action class runs.. as
if validation were ok.. even if I do not fill "name" field in my form?

I guess there's something wrong.. but I don't know where ?

Help please !

-- 
~ jebmail ~

Re: pb using validator it does not work !

Posted by Jeremy Jardin <je...@gmail.com>.
>
> A couple of things:
>
> 1.  Not sure what version of Struts you're using, but at least according
> to
> http://struts.apache.org/1.2.9/userGuide/building_view.html#validator,
> the "property" attribute for the validator should have the value of
> "pathnames" and not the path of your action.


It's ok I had just tried with that value for test.. but it doesn't work :-/

2.  Make sure your bean extends ValidatorForm (or the Dyna one if using
> dyna forms...)


yes, i'st ok

Fix the above and see what happens.  If it's still not working, override
> the validate(...) method in your validator form bean and throw either
> some System.out's or Logger.log statements in there to make sure it's
> even being called.  Also, if you override, make sure you call
> super.validate to get any errors you've defined in your validation XML.


Should I really override that method ???



Hope this helps...
>
> cheers,
>
> -adam
>
> Jeremy Jardin wrote:
> > Hi,
> >
> > I'm trying to use validator plugin in my application, and it does not
> > work
> > at all !
> >
> > First, I've just add <html:errors/> in my jsp.
> >
> > I've written a basic validation.xml file like this :
> > <form name="StartSubscriptionForm">
> >    <field property="name" depends="required">
> >        <arg0 key="inscription.nom"/>
> >    </field>
> > </form>
> >
> > Then, I've also a classic validation-rules.xml file, with usefull rules.
> > Thoses files are un my WEB-INF directory.
> >
> > I added in my struts-config.xml fil those lines :
> >
> >   <form-beans>
> >  <form-bean name="StartSubscriptionForm" type="
> > sapinscription.form.StartSubscriptionForm"/>
> >
> >    </form-beans>
> >
> >  <!-- ========== Action Mapping Definitions
> > ==============================
> > -->
> >  <action-mappings>
> >
> >    <action    path      = "/StartSubscription"
> >               type      =
> > "sapinscription.action.StartSubscriptionAction"
> >               name      = "StartSubscriptionForm"
> >               scope     = "session"
> >               validate  = "true"
> >               input     = "/jsp/inscriptionForm.jsp"
> >      >
> >        <forward name="subscribingPage" path="/jsp/inscriptionForm.jsp"
> > />
> >     </action>
> >
> >    </action-mappings>
> >
> >  <message-resources null="false" parameter="conf.WebMessages"/>
> >
> > <!-- ============== Validator plugin
> > ======================================-->
> >
> >  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
> >    <set-property
> >        property="/StartSubscription"
> >        value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
> >  </plug-in>
> >
> >
> > It seems to be all right.. but when I submit my form, Action class
> > runs.. as
> > if validation were ok.. even if I do not fill "name" field in my form?
> >
> > I guess there's something wrong.. but I don't know where ?
> >
> > Help please !
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
~ jebmail ~

Re: pb using validator it does not work !

Posted by Adam Gordon <ad...@readytalk.com>.
Jeremy-

A couple of things:

1.  Not sure what version of Struts you're using, but at least according 
to 
http://struts.apache.org/1.2.9/userGuide/building_view.html#validator, 
the "property" attribute for the validator should have the value of 
"pathnames" and not the path of your action.

2.  Make sure your bean extends ValidatorForm (or the Dyna one if using 
dyna forms...)

Fix the above and see what happens.  If it's still not working, override 
the validate(...) method in your validator form bean and throw either 
some System.out's or Logger.log statements in there to make sure it's 
even being called.  Also, if you override, make sure you call 
super.validate to get any errors you've defined in your validation XML.

Hope this helps...

cheers,

-adam

Jeremy Jardin wrote:
> Hi,
>
> I'm trying to use validator plugin in my application, and it does not
> work
> at all !
>
> First, I've just add <html:errors/> in my jsp.
>
> I've written a basic validation.xml file like this :
> <form name="StartSubscriptionForm">
>    <field property="name" depends="required">
>        <arg0 key="inscription.nom"/>
>    </field>
> </form>
>
> Then, I've also a classic validation-rules.xml file, with usefull rules.
> Thoses files are un my WEB-INF directory.
>
> I added in my struts-config.xml fil those lines :
>
>   <form-beans>
>  <form-bean name="StartSubscriptionForm" type="
> sapinscription.form.StartSubscriptionForm"/>
>
>    </form-beans>
>
>  <!-- ========== Action Mapping Definitions
> ==============================
> -->
>  <action-mappings>
>
>    <action    path      = "/StartSubscription"
>               type      =
> "sapinscription.action.StartSubscriptionAction"
>               name      = "StartSubscriptionForm"
>               scope     = "session"
>               validate  = "true"
>               input     = "/jsp/inscriptionForm.jsp"
>      >
>        <forward name="subscribingPage" path="/jsp/inscriptionForm.jsp"
> />
>     </action>
>
>    </action-mappings>
>
>  <message-resources null="false" parameter="conf.WebMessages"/>
>
> <!-- ============== Validator plugin
> ======================================-->
>
>  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
>    <set-property
>        property="/StartSubscription"
>        value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
>  </plug-in>
>
>
> It seems to be all right.. but when I submit my form, Action class
> runs.. as
> if validation were ok.. even if I do not fill "name" field in my form?
>
> I guess there's something wrong.. but I don't know where ?
>
> Help please !
>

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


Re: pb using validator it does not work !

Posted by Wendy Smoak <ws...@gmail.com>.
On 7/20/06, Jeremy Jardin <je...@gmail.com> wrote:

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

That looks odd.  Try setting the 'pathnames' property instead.

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

-- 
Wendy

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


Re: About ActionServlet

Posted by David Evans <ds...@berndtgroup.net>.
The API docs can help:
http://struts.apache.org/1.x/struts-core/apidocs/index.html
more specifically:
http://struts.apache.org/1.x/struts-core/apidocs/org/apache/struts/action/ActionServlet.html

This link has a brief explanation
http://struts.apache.org/1.2.x/userGuide/building_controller.html#action_servlet

as it notes, most of the actual functionality is delegated to the
RequestProcessor:
http://struts.apache.org/1.2.x/userGuide/building_controller.html#request_processor

You can download the source code and look at the RequestProcessor class
to see what is actually happening:
http://struts.apache.org/download.cgi

hope that helps.

dave

On Thu, 2006-07-20 at 15:56 +0530, sunil.prabhu wrote:
> Hi there,
> 
> I am new to struts framework and I have been reading lot of books regarding
> the same. But I am not able to make it out what exactly is ActionServlet.
> And what does it contain....can any body please provide me with sufficient
> information or any link which contains the same....
> 
> ThanQ
> Sunil
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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


About ActionServlet

Posted by "sunil.prabhu" <su...@exensys.com>.
Hi there,

I am new to struts framework and I have been reading lot of books regarding
the same. But I am not able to make it out what exactly is ActionServlet.
And what does it contain....can any body please provide me with sufficient
information or any link which contains the same....

ThanQ
Sunil




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