You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kjersti Berg <kj...@gmail.com> on 2005/07/05 14:21:58 UTC

Validating nested, indexed properties

Hi

I would like to validate some nested, indexed properties on my form.
I've googled and found someone having similar problems, but haven't
found a solution yet. Any help would be great.

The form contains a list of Job objects, each having a set of
properties, let's say number and size. I tried to define the
validation like this:

<field property="number" indexedListProperty="jobs" depends="integer">
   <arg0 key="absence.label.unitOfAbsence"/>
</field> 
<field property="size" indexedListProperty="jobs" depends="integer">
   <arg0 key="absence.label.scale"/>
</field>

This does not work, although as far as I can tell, this is how the
documentation recommends using it.

However, in the jsp, the values are collected using the nested tag,
not the logic/bean tags.
<nested:iterate property="jobs">
   <nested:text property="number"/> 
   <nested:text property="size"/>
</nested:iterate>

Would this interfere with the validation, or are the two tags
identical when it comes to validation?

I'm using Struts 1.1. 

Kjersti

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


Re: Validating nested, indexed properties

Posted by Kjersti Berg <kj...@gmail.com>.
I should probably slap myself now. This works just fine, if the
struts-config doesn't turn validation off. :)

Kjersti

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


Re: Validating nested, indexed properties

Posted by Kjersti Berg <kj...@gmail.com>.
On 07/07/05, Hubert Rabago <hr...@gmail.com> wrote:
> What do you mean when you say it doesn't work?

I mean that when I input characters in an integer-only field, the
validation is not triggered, the values are just set on the form.

However, I have tried to dig a bit more into this, and have looked at
the html generated. And it looks like it might have something todo
with the fact that we are running struts inside a portal. The plain
form attributes are prefixed with a string by the portal, but the
attributes defined using nested, are not. The odd thing though, is
that the values do get to the form, they just don't seem to be
validated. Does the Validator reference the form attributes in a
different way then the form population?

Any ideas? 

Kjersti

> I compared your code with something I have that's working and they
> look pretty much the same.  I have a form with a list of employees,
> and each employee has fields such as "birth".
> 
> The HTML form looks something like this:
> <nested:iterate property="employees">
>        <nested:text property="birth" size="10" maxlength="10"/>
>        <nested:text property="ssNumber" size="9" maxlength="9"/>
>        <nested:text property="salary" size="12"/>
>    </TR>
> </nested:iterate>
> 
> Validation rules look like this:
> 
>            <field property="birth" indexedListProperty="employees"
> depends="required,date">
>                <arg0 key="employeeform.birth.displayname"/>
>                <var>
>                    <var-name>datePatternStrict</var-name>
>                    <var-value>MM/dd/yyyy</var-value>
>                </var>
>            </field>
>            <field property="ssNumber" indexedListProperty="employees"
>                     depends="required,integer">
>                <arg0 key="employeeform.ssnumber.displayname"/>
>            </field>
>            <field property="salary" indexedListProperty="employees"
>                     depends="required,mask">
>                <arg0 key="employeeform.salary.displayname"/>
>                <var>
>                    <var-name>mask</var-name>
>                    <var-value>^\$?\d+(,\d{3})*(\.\d{2})?$</var-value>
>                </var>
>            </field>
> 
> This app is using Struts 1.2, though.  If you want to try it out, it's
> available at http://www.rabago.net/struts/formdef/dev/nested.war .
> It's using FormDef (which is a Struts plugin) but FormDef doesn't
> affect validation, so the same rules apply.  Using nested tags also
> don't affect validation.  In fact, you could use plain old HTML tags
> and still use Validator, as long as you name your fields correctly
> and/or populate your form beans properly.
> 
> Hubert
>

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


Re: Validating nested, indexed properties

Posted by Hubert Rabago <hr...@gmail.com>.
What do you mean when you say it doesn't work?  
I compared your code with something I have that's working and they
look pretty much the same.  I have a form with a list of employees,
and each employee has fields such as "birth".

The HTML form looks something like this:
<nested:iterate property="employees">     
        <nested:text property="birth" size="10" maxlength="10"/>
        <nested:text property="ssNumber" size="9" maxlength="9"/>
        <nested:text property="salary" size="12"/>
    </TR>
</nested:iterate>

Validation rules look like this:

            <field property="birth" indexedListProperty="employees"
depends="required,date">
                <arg0 key="employeeform.birth.displayname"/>
                <var>
                    <var-name>datePatternStrict</var-name>
                    <var-value>MM/dd/yyyy</var-value>
                </var>
            </field>
            <field property="ssNumber" indexedListProperty="employees"
                     depends="required,integer">
                <arg0 key="employeeform.ssnumber.displayname"/>
            </field>
            <field property="salary" indexedListProperty="employees" 
                     depends="required,mask">
                <arg0 key="employeeform.salary.displayname"/>
                <var>
                    <var-name>mask</var-name>
                    <var-value>^\$?\d+(,\d{3})*(\.\d{2})?$</var-value>
                </var>
            </field>

This app is using Struts 1.2, though.  If you want to try it out, it's
available at http://www.rabago.net/struts/formdef/dev/nested.war . 
It's using FormDef (which is a Struts plugin) but FormDef doesn't
affect validation, so the same rules apply.  Using nested tags also
don't affect validation.  In fact, you could use plain old HTML tags
and still use Validator, as long as you name your fields correctly
and/or populate your form beans properly.

Hubert


On 7/5/05, Kjersti Berg <kj...@gmail.com> wrote:
> Hi
> 
> I would like to validate some nested, indexed properties on my form.
> I've googled and found someone having similar problems, but haven't
> found a solution yet. Any help would be great.
> 
> The form contains a list of Job objects, each having a set of
> properties, let's say number and size. I tried to define the
> validation like this:
> 
> <field property="number" indexedListProperty="jobs" depends="integer">
>    <arg0 key="absence.label.unitOfAbsence"/>
> </field>
> <field property="size" indexedListProperty="jobs" depends="integer">
>    <arg0 key="absence.label.scale"/>
> </field>
> 
> This does not work, although as far as I can tell, this is how the
> documentation recommends using it.
> 
> However, in the jsp, the values are collected using the nested tag,
> not the logic/bean tags.
> <nested:iterate property="jobs">
>    <nested:text property="number"/>
>    <nested:text property="size"/>
> </nested:iterate>
> 
> Would this interfere with the validation, or are the two tags
> identical when it comes to validation?
> 
> I'm using Struts 1.1.
> 
> Kjersti
>

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


Re: forwarding out

Posted by Aleksandar Matijaca <am...@gmail.com>.
I would not "actionforward", I would just get a servlet context, and 
redirect....

a.m.



On 7/5/05, Lucas Bern <lu...@yahoo.com.ar> wrote:
> 
> 
> Hi all
> 
> I neeed to forwars form my action to a page out side my context...
> 
> something like return new ActionForward("www.google.com<http://www.google.com>
> ");
> 
> does anybody know haw to do it??
> 
> 
> 
> thanks
> 
> 
> ---------------------------------
> 1GB gratis, Antivirus y Antispam
> Correo Yahoo!, el mejor correo web del mundo
> Abrí tu cuenta aquí
>

Re: forwarding out

Posted by Viktar Duzh <du...@tut.by>.
The following will work:

new ActionForward("http://www.google.com", true);

Regards,

-- Viktar

----- Original Message ----- 
From: "Lucas Bern" <lu...@yahoo.com.ar>
To: "Struts Users Mailing List" <us...@struts.apache.org>; "Kjersti Berg" 
<kj...@gmail.com>
Sent: Tuesday, July 05, 2005 4:14 PM
Subject: forwarding out


>
> Hi all
>
> I neeed to forwars form my action to a page out side my context...
>
> something like return new ActionForward("www.google.com");
>
> does anybody know haw to do it??
>
>
>
> thanks
>
>
> ---------------------------------
> 1GB gratis, Antivirus y Antispam
> Correo Yahoo!, el mejor correo web del mundo
> Abrí tu cuenta aquí 


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


forwarding out

Posted by Lucas Bern <lu...@yahoo.com.ar>.
Hi all

 I neeed to forwars form my action to a page out side my context...

something like return new ActionForward("www.google.com");

does anybody know haw to do it??

 

thanks

		
---------------------------------
 1GB gratis, Antivirus y Antispam
 Correo Yahoo!, el mejor correo web del mundo
 Abrí tu cuenta aquí