You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Stavrianou <ch...@gmail.com> on 2004/08/21 12:59:43 UTC
Newbie Validator Basic Configuration
Hi,
I am attempting to use Validator with DynaValidatorActionForms - but
can't get the Validator Plugin to work.
Even the most basic form refuses to validate - please help.
I have followed all FAQ - Mailing lists and books that I can find.
Please find following relevant sections from Login.jsp,
Struts-Config.xml, and Validation.xml
Thanks
Chris Stav
-----------------
//Struts-Config.xml
<form-beans>
<form-bean name="loginForm"
type="org.apache.struts.validator.DynaValidatorActionForm">
<form-property name="username" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
</form-bean>
</form-beans>
....
<action path="/loginpage"
type="org.apache.struts.actions.ForwardAction"
parameter="login.main"/>
<action path="/login" type="com.FooBar.LoginAction"
name="loginForm" scope="request" validate="true"
input="/loginpage.do">
<forward name="admin" path="/admin/mainmenu.do" redirect="true"/>
<forward name="super" path="/super/mainmenu.do" redirect="true"/>
<forward name="user" path="/user/mainmenu.do" redirect="true"/>
<forward name="failure" path="/loginerror.do" redirect="true"/>
</action>
....
<!-- ========== Validation plugin =================== -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml"/>
</plug-in>
-------------------------
//Validation.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules
Configuration 1.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
<form-validation>
<global>
</global>
<formset>
<form name="/login">
<field propery="username" depends="required">
<arg0 key="Username" resource="false"/>
</field>
<field propery="password" depends="required">
<arg0 key="Password" resource="false"/>
</field>
</form>
</formset>
</form-validation>
------------------------
//Login.jsp
<logic:notPresent name="<%= ValidatorPlugIn.VALIDATOR_KEY %>"
scope="application">
<font color="red">
ERROR: Validator resources not loaded -- check Commons Logging
logs for error messages.
</font>
</logic:notPresent>
<html:errors/>
<html:form action="/login">
<DIV ALIGN="CENTER">
<table>
<tr><td class="loginborder">
<table>
<tr><td>
<TABLE>
<tr><td class="logincell">User Name:</TD>
<TD class="logincell"><html:text property="username"/></TD></TR>
<tr><td class="logincell">Password:</TD>
<TD class="logincell"><html:password property="password"/>
</td></tr>
</table>
</td></tr>
<tr><td>
<html:submit/>
</td></tr>
</table>
</td>
</tr>
</table>
</DIV>
</html:form>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Newbie Validator Basic Configuration
Posted by Chris Stavrianou <ch...@gmail.com>.
In my validator.xml file it uses the path of the action - see original post.
I have tried the validator with the DynaValidatorForm and
validator.xml referencing the name of the form not the action path -
alas this didn't work.
Thanks
Chris Stav.
On Sat, 21 Aug 2004 14:14:03 +0200, Matthias Wessendorf
<ma...@matthias-wessendorf.de> wrote:
> DynaValidatorActionForm
> is for forms, that contain more than *one* page
> (like a wizzard or a poll)
>
> in validation.xml you must enter on
> name attribute the PATH of the action ->
>
> name="/submit1"...
>
> but I guess you want a Validator for a single page
>
> so use DynaValidatorForm
> now in vali.xml you must edit something like this:
> name="nameOfTheBeanInMyStrutsConfigFile"...
>
> hope it helps,
>
> Regards,
> Matthias
>
>
> > -----Original Message-----
> > From: Chris Stavrianou [mailto:chrisonmaui@gmail.com]
> > Sent: Saturday, August 21, 2004 1:00 PM
> > To: user@struts.apache.org
> > Subject: Newbie Validator Basic Configuration
> >
> >
> > Hi,
> >
> > I am attempting to use Validator with
> > DynaValidatorActionForms - but can't get the Validator Plugin to work.
> >
> > Even the most basic form refuses to validate - please help.
> >
> > I have followed all FAQ - Mailing lists and books that I can find.
> >
> > Please find following relevant sections from Login.jsp,
> > Struts-Config.xml, and Validation.xml
> >
> >
> > Thanks
> >
> > Chris Stav
> >
> > -----------------
> > //Struts-Config.xml
> >
> > <form-beans>
> >
> > <form-bean name="loginForm"
> > type="org.apache.struts.validator.DynaValidatorActionForm">
> > <form-property name="username" type="java.lang.String"/>
> > <form-property name="password" type="java.lang.String"/>
> > </form-bean>
> > </form-beans>
> >
> > ....
> >
> > <action path="/loginpage"
> > type="org.apache.struts.actions.ForwardAction"
> > parameter="login.main"/>
> >
> > <action path="/login" type="com.FooBar.LoginAction"
> > name="loginForm" scope="request" validate="true"
> > input="/loginpage.do">
> > <forward name="admin" path="/admin/mainmenu.do"
> > redirect="true"/>
> > <forward name="super" path="/super/mainmenu.do"
> > redirect="true"/>
> > <forward name="user" path="/user/mainmenu.do"
> > redirect="true"/>
> > <forward name="failure" path="/loginerror.do"
> > redirect="true"/>
> > </action>
> > ....
> >
> > <!-- ========== Validation plugin =================== -->
> >
> > <plug-in
> > className="org.apache.struts.validator.ValidatorPlugIn">
> > <set-property
> > property="pathnames"
> > value="/WEB-INF/validator-rules.xml,
> > /WEB-INF/validation.xml"/>
> > </plug-in>
> >
> > -------------------------
> > //Validation.xml
> >
> > <?xml version="1.0" encoding="ISO-8859-1" ?>
> >
> > <!DOCTYPE form-validation PUBLIC
> > "-//Apache Software Foundation//DTD Commons
> > Validator Rules Configuration 1.0//EN"
> > "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
> >
> >
> > <form-validation>
> >
> > <global>
> > </global>
> >
> > <formset>
> >
> > <form name="/login">
> > <field propery="username"
> > depends="required">
> > <arg0 key="Username" resource="false"/>
> > </field>
> > <field propery="password"
> > depends="required">
> > <arg0 key="Password" resource="false"/>
> > </field>
> > </form>
> >
> > </formset>
> >
> > </form-validation>
> >
> > ------------------------
> > //Login.jsp
> >
> > <logic:notPresent name="<%= ValidatorPlugIn.VALIDATOR_KEY %>"
> > scope="application">
> > <font color="red">
> > ERROR: Validator resources not loaded -- check Commons Logging
> > logs for error messages.
> > </font>
> > </logic:notPresent>
> > <html:errors/>
> >
> > <html:form action="/login">
> > <DIV ALIGN="CENTER">
> > <table>
> > <tr><td class="loginborder">
> >
> > <table>
> > <tr><td>
> > <TABLE>
> > <tr><td class="logincell">User Name:</TD>
> > <TD class="logincell"><html:text
> > property="username"/></TD></TR> <tr><td
> > class="logincell">Password:</TD> <TD
> > class="logincell"><html:password property="password"/>
> > </td></tr> </table> </td></tr>
> >
> > <tr><td>
> > <html:submit/>
> > </td></tr>
> > </table>
> >
> > </td>
> > </tr>
> > </table>
> > </DIV>
> >
> > </html:form>
> >
> > ---------------------------------------------------------------------
> > 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
How to set up 'userProfile' bean in session for ProcessAction?
Posted by struts Dude <sc...@slingshot.co.nz>.
Hi
How would I set up to add a "userProfile"
form object in my struts-config.xml and store
user info in it so that ProcessAction from
Scaffold will merge information coming from
the request form (ActionForm) and the userProfile
form and pass them to the execute method of
my business bean (ProcessBean)?
I can only think of storing'userProfile'bean in
session when user login. Dunno if that's how
u ppl do it.
Under what scenario would I need "userProfile" bean
so it works well with ProcessAction? I guess I am
not convinced they are useful.
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Newbie Validator Basic Configuration
Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
DynaValidatorActionForm
is for forms, that contain more than *one* page
(like a wizzard or a poll)
in validation.xml you must enter on
name attribute the PATH of the action ->
name="/submit1"...
but I guess you want a Validator for a single page
so use DynaValidatorForm
now in vali.xml you must edit something like this:
name="nameOfTheBeanInMyStrutsConfigFile"...
hope it helps,
Regards,
Matthias
> -----Original Message-----
> From: Chris Stavrianou [mailto:chrisonmaui@gmail.com]
> Sent: Saturday, August 21, 2004 1:00 PM
> To: user@struts.apache.org
> Subject: Newbie Validator Basic Configuration
>
>
> Hi,
>
> I am attempting to use Validator with
> DynaValidatorActionForms - but can't get the Validator Plugin to work.
>
> Even the most basic form refuses to validate - please help.
>
> I have followed all FAQ - Mailing lists and books that I can find.
>
> Please find following relevant sections from Login.jsp,
> Struts-Config.xml, and Validation.xml
>
>
> Thanks
>
> Chris Stav
>
> -----------------
> //Struts-Config.xml
>
> <form-beans>
>
> <form-bean name="loginForm"
> type="org.apache.struts.validator.DynaValidatorActionForm">
> <form-property name="username" type="java.lang.String"/>
> <form-property name="password" type="java.lang.String"/>
> </form-bean>
> </form-beans>
>
> ....
>
> <action path="/loginpage"
> type="org.apache.struts.actions.ForwardAction"
> parameter="login.main"/>
>
> <action path="/login" type="com.FooBar.LoginAction"
> name="loginForm" scope="request" validate="true"
> input="/loginpage.do">
> <forward name="admin" path="/admin/mainmenu.do"
> redirect="true"/>
> <forward name="super" path="/super/mainmenu.do"
> redirect="true"/>
> <forward name="user" path="/user/mainmenu.do"
> redirect="true"/>
> <forward name="failure" path="/loginerror.do"
> redirect="true"/>
> </action>
> ....
>
> <!-- ========== Validation plugin =================== -->
>
> <plug-in
> className="org.apache.struts.validator.ValidatorPlugIn">
> <set-property
> property="pathnames"
> value="/WEB-INF/validator-rules.xml,
> /WEB-INF/validation.xml"/>
> </plug-in>
>
> -------------------------
> //Validation.xml
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
>
> <!DOCTYPE form-validation PUBLIC
> "-//Apache Software Foundation//DTD Commons
> Validator Rules Configuration 1.0//EN"
> "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
>
>
> <form-validation>
>
> <global>
> </global>
>
> <formset>
>
> <form name="/login">
> <field propery="username"
> depends="required">
> <arg0 key="Username" resource="false"/>
> </field>
> <field propery="password"
> depends="required">
> <arg0 key="Password" resource="false"/>
> </field>
> </form>
>
> </formset>
>
> </form-validation>
>
> ------------------------
> //Login.jsp
>
> <logic:notPresent name="<%= ValidatorPlugIn.VALIDATOR_KEY %>"
> scope="application">
> <font color="red">
> ERROR: Validator resources not loaded -- check Commons Logging
> logs for error messages.
> </font>
> </logic:notPresent>
> <html:errors/>
>
> <html:form action="/login">
> <DIV ALIGN="CENTER">
> <table>
> <tr><td class="loginborder">
>
> <table>
> <tr><td>
> <TABLE>
> <tr><td class="logincell">User Name:</TD>
> <TD class="logincell"><html:text
> property="username"/></TD></TR> <tr><td
> class="logincell">Password:</TD> <TD
> class="logincell"><html:password property="password"/>
> </td></tr> </table> </td></tr>
>
> <tr><td>
> <html:submit/>
> </td></tr>
> </table>
>
> </td>
> </tr>
> </table>
> </DIV>
>
> </html:form>
>
> ---------------------------------------------------------------------
> 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