You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sebastian Stein <se...@gmx.de> on 2006/07/14 22:44:45 UTC

Problem with validation rule

Hi,

I have a form, which should also use validation based on a mask. I already
enabled this kind of validation in another form and there it works. So I
guess I just have a type or did something wrong during copy&paste. Here is
the form definition in the struts-config.xml:

      <form-bean name="menuForm"
                 type="org.contineo.forms.MenuForm">
         <form-property name="menuText"
                        type="java.lang.String"/>
      </form-bean>

...

      <action input="/AddMenu.do"
              name="menuForm"
              path="/SaveMenu"
              scope="request"
              type="org.contineo.actions.admin.menu.SaveMenuAction"
              validate="true">
         <forward name="addmenu"
                  path="/pages/addMenu.jsp"
                  redirect="false"/>
      </action>

And here is the validation rule:

      <form name="menuForm">
         <field property="menuText"
                depends="requireList,mask">
            <var>
               <var-name>count</var-name>
               <var-value>1</var-value>
            </var>
            <var>
               <var-name>field0</var-name>
               <var-value>menuGroup</var-value>
            </var>
            <var>
               <var-name>mask</var-name>
               <var-value>^[a-zA-Z]*$</var-value>
            </var>
            <msg name="menuForm.menuText"
                 key="errors.required"
                 resource="true"/>
            <msg name="mask"
                 key="errors.val.username"
                 resource="true"/>
         </field>
      </form>

Interestingly the requireList validation rule works. So if the user does not
select something in field0, the validation fails. However, the mask rule is
not applied. It seems the content of menuText is not checked against the
pattern.

Does anybody can spot the error? I'm using Struts 1.1.


Sebastian

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


Re: Problem with validation rule

Posted by Sebastian Stein <se...@gmx.de>.
Sebastian Stein <se...@gmx.de> [060716 11:50]:
> Adam Gordon <ad...@readytalk.com> [060715 09:50]:
> > What happens if you remove the "requireList" dependency and just use "mask?"
> 
> It is driving me crazy. I removed the requireList dependency and nothing
> changed. I removed the complete validation for menuForm from validation.xml
> and nothing changed. I changed validate="true" to false in struts-config.xml
> and nothing changed. Also I deleted all the tomcat generated files in the
> tomcat/work directly, but nothing changed. However, if I change for example
> the struts-config.xml file in a way that it uses another jsp than at least
> another jsp is shown.
> 
> There seems to go something completely wired going on and I have no idea
> what it is. Is there another point where one can define validation rules for
> a form?

I found it. The form was not extending ValidatorForm but instead ActionForm.


Sebastian

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


Re: Problem with validation rule

Posted by Sebastian Stein <se...@gmx.de>.
Adam Gordon <ad...@readytalk.com> [060715 09:50]:
> What happens if you remove the "requireList" dependency and just use "mask?"

It is driving me crazy. I removed the requireList dependency and nothing
changed. I removed the complete validation for menuForm from validation.xml
and nothing changed. I changed validate="true" to false in struts-config.xml
and nothing changed. Also I deleted all the tomcat generated files in the
tomcat/work directly, but nothing changed. However, if I change for example
the struts-config.xml file in a way that it uses another jsp than at least
another jsp is shown.

There seems to go something completely wired going on and I have no idea
what it is. Is there another point where one can define validation rules for
a form?


Sebastian


> Sebastian Stein wrote:
> >Hi,
> >
> >I have a form, which should also use validation based on a mask. I already
> >enabled this kind of validation in another form and there it works. So I
> >guess I just have a type or did something wrong during copy&paste. Here is
> >the form definition in the struts-config.xml:
> >
> >      <form-bean name="menuForm"
> >                 type="org.contineo.forms.MenuForm">
> >         <form-property name="menuText"
> >                        type="java.lang.String"/>
> >      </form-bean>
> >
> >...
> >
> >      <action input="/AddMenu.do"
> >              name="menuForm"
> >              path="/SaveMenu"
> >              scope="request"
> >              type="org.contineo.actions.admin.menu.SaveMenuAction"
> >              validate="true">
> >         <forward name="addmenu"
> >                  path="/pages/addMenu.jsp"
> >                  redirect="false"/>
> >      </action>
> >
> >And here is the validation rule:
> >
> >      <form name="menuForm">
> >         <field property="menuText"
> >                depends="requireList,mask">
> >            <var>
> >               <var-name>count</var-name>
> >               <var-value>1</var-value>
> >            </var>
> >            <var>
> >               <var-name>field0</var-name>
> >               <var-value>menuGroup</var-value>
> >            </var>
> >            <var>
> >               <var-name>mask</var-name>
> >               <var-value>^[a-zA-Z]*$</var-value>
> >            </var>
> >            <msg name="menuForm.menuText"
> >                 key="errors.required"
> >                 resource="true"/>
> >            <msg name="mask"
> >                 key="errors.val.username"
> >                 resource="true"/>
> >         </field>
> >      </form>
> >
> >Interestingly the requireList validation rule works. So if the user does 
> >not
> >select something in field0, the validation fails. However, the mask rule is
> >not applied. It seems the content of menuText is not checked against the
> >pattern.
> >
> >Does anybody can spot the error? I'm using Struts 1.1.
> >
> >
> >Sebastian
> >
> >---------------------------------------------------------------------
> >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
> 

-- 
http://www.hpfsc.de/ - die Seite rund um:
Assembler, Bundeswehr, TFT LCDs, Halle/Saale, Fahrradtouren, Neuseeland,
Wanderstaat Mauma, Raumschiff USS Nathan, Enemy Room, MLCAD Tutorial

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


Re: Problem with validation rule

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

What happens if you remove the "requireList" dependency and just use "mask?"

-Adam

Sebastian Stein wrote:
> Hi,
>
> I have a form, which should also use validation based on a mask. I already
> enabled this kind of validation in another form and there it works. So I
> guess I just have a type or did something wrong during copy&paste. Here is
> the form definition in the struts-config.xml:
>
>       <form-bean name="menuForm"
>                  type="org.contineo.forms.MenuForm">
>          <form-property name="menuText"
>                         type="java.lang.String"/>
>       </form-bean>
>
> ...
>
>       <action input="/AddMenu.do"
>               name="menuForm"
>               path="/SaveMenu"
>               scope="request"
>               type="org.contineo.actions.admin.menu.SaveMenuAction"
>               validate="true">
>          <forward name="addmenu"
>                   path="/pages/addMenu.jsp"
>                   redirect="false"/>
>       </action>
>
> And here is the validation rule:
>
>       <form name="menuForm">
>          <field property="menuText"
>                 depends="requireList,mask">
>             <var>
>                <var-name>count</var-name>
>                <var-value>1</var-value>
>             </var>
>             <var>
>                <var-name>field0</var-name>
>                <var-value>menuGroup</var-value>
>             </var>
>             <var>
>                <var-name>mask</var-name>
>                <var-value>^[a-zA-Z]*$</var-value>
>             </var>
>             <msg name="menuForm.menuText"
>                  key="errors.required"
>                  resource="true"/>
>             <msg name="mask"
>                  key="errors.val.username"
>                  resource="true"/>
>          </field>
>       </form>
>
> Interestingly the requireList validation rule works. So if the user does not
> select something in field0, the validation fails. However, the mask rule is
> not applied. It seems the content of menuText is not checked against the
> pattern.
>
> Does anybody can spot the error? I'm using Struts 1.1.
>
>
> Sebastian
>
> ---------------------------------------------------------------------
> 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