You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fea jabi <zy...@hotmail.com> on 2005/12/19 20:26:09 UTC

DynaValidatorForm and nested tags.

I have a jsp which is FORM1

using DynaValidatorForm for this.

there is a table in this which has to display they the contents other form? 
can we do this using DynaValidatorForm? i.e one of it's attribute being 
another form?


Also, when exactly do we have to use the nested tags?

Thanks.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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


Re: DynaValidatorForm and nested tags.

Posted by fea jabi <zy...@hotmail.com>.
thanks, Laurie.

Now I can think of an alternative way to do this. I filed an enhancement 
request in Bugzilla.


>From: Laurie Harper <la...@holoweb.net>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: user@struts.apache.org
>Subject: Re: DynaValidatorForm and nested tags.
>Date: Tue, 20 Dec 2005 22:45:09 -0500
>
>I'm pretty sure that isn't supported; I wanted to do exactly that recently 
>but, looking through the code, it appears you can't. It seems like it'd be 
>a pretty useful thing to be able to do, though. Maybe you could file an 
>enhancement request in Bugzilla.
>
>L.
>
>fea jabi wrote:
>>I was under the imporession that something like this should work
>>
>><form-bean name="Form1" type="org.apache.struts.action.DynaActionForm" 
>>dynamic="true">
>>         <form-property name="property1" type="java.lang.Integer"/>
>>         <form-property name="property2" type="java.lang.Integer"/>
>></form-bean>
>>
>><form-bean name="Form2" 
>>type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
>>         <form-property name="hrs" type="Form1"/>
>>        <form-property name="property3" type="java.lang.Integer"/>
>>......................
>>...................
>>....................
>></form-bean>
>>
>>can't we do this?
>>
>>
>>>From: Rick Reumann <ri...@gmail.com>
>>>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>>>To: Struts Users Mailing List <us...@struts.apache.org>
>>>Subject: Re: DynaValidatorForm and nested tags.
>>>Date: Mon, 19 Dec 2005 20:25:54 -0500
>>>
>>>On 12/19/05, fea jabi <zy...@hotmail.com> wrote:
>>> >
>>> > Thanks. I sure can see the difference.
>>> >
>>> > can we use a DynaValidatorForm as an attribute in another
>>> > DynaValidatorForm?
>>>
>>>
>>>
>>>I'm guessing you could just simply nest DynaValidatorForms (but I'm sure
>>>you'll want to use 'Lazy' ones otherwise you'll have some problems when 
>>>the
>>>form submits - indexOutOfBoundsExceptions), but I think it might be 
>>>cleaner
>>>to just nest a LazyDynaBean as a property of your LazyDynaForm. Others on
>>>this List have much more experience working with DynaBeans/Forms than me, 
>>>so
>>>they might have better suggestions.
>>>
>>>More about it here:
>>>http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html
>>>
>>>Notice on that page at the end...
>>>
>>><struts-config>
>>>
>>>        <form-beans>
>>>            <form-bean name="restrictedForm"
>>>type="org.apache.struts.validator.LazyValidatorForm">
>>>                *<set-property property="restricted" value="true"/>*
>>>                <form-property name="orderNumber" 
>>>type="java.lang.Integer" />
>>>                <form-property name="customerName" 
>>>type="java.lang.String" />
>>>                <form-property name="orderValue" 
>>>type="java.lang.BigDecimal" />
>>>                <form-property name="orderLines"
>>>type="org.apache.commons.beanutils.LazyDynaBean[]" />
>>>            </form-bean>
>>>        </form-beans>
>>>     </struts-config>
>>>
>>>
>>>
>>>
>>>
>>>--
>>>Rick
>>
>>_________________________________________________________________
>>Express yourself instantly with MSN Messenger! Download today - it's FREE! 
>>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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


Re: DynaValidatorForm and nested tags.

Posted by Laurie Harper <la...@holoweb.net>.
I'm pretty sure that isn't supported; I wanted to do exactly that 
recently but, looking through the code, it appears you can't. It seems 
like it'd be a pretty useful thing to be able to do, though. Maybe you 
could file an enhancement request in Bugzilla.

L.

fea jabi wrote:
> I was under the imporession that something like this should work
> 
> <form-bean name="Form1" type="org.apache.struts.action.DynaActionForm" 
> dynamic="true">
>         <form-property name="property1" type="java.lang.Integer"/>
>         <form-property name="property2" type="java.lang.Integer"/>
> </form-bean>
> 
> <form-bean name="Form2" 
> type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
>         <form-property name="hrs" type="Form1"/>
>        <form-property name="property3" type="java.lang.Integer"/>
> ......................
> ...................
> ....................
> </form-bean>
> 
> can't we do this?
> 
> 
>> From: Rick Reumann <ri...@gmail.com>
>> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>> To: Struts Users Mailing List <us...@struts.apache.org>
>> Subject: Re: DynaValidatorForm and nested tags.
>> Date: Mon, 19 Dec 2005 20:25:54 -0500
>>
>> On 12/19/05, fea jabi <zy...@hotmail.com> wrote:
>> >
>> > Thanks. I sure can see the difference.
>> >
>> > can we use a DynaValidatorForm as an attribute in another
>> > DynaValidatorForm?
>>
>>
>>
>> I'm guessing you could just simply nest DynaValidatorForms (but I'm sure
>> you'll want to use 'Lazy' ones otherwise you'll have some problems 
>> when the
>> form submits - indexOutOfBoundsExceptions), but I think it might be 
>> cleaner
>> to just nest a LazyDynaBean as a property of your LazyDynaForm. Others on
>> this List have much more experience working with DynaBeans/Forms than 
>> me, so
>> they might have better suggestions.
>>
>> More about it here:
>> http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html
>>
>> Notice on that page at the end...
>>
>> <struts-config>
>>
>>        <form-beans>
>>            <form-bean name="restrictedForm"
>> type="org.apache.struts.validator.LazyValidatorForm">
>>                *<set-property property="restricted" value="true"/>*
>>                <form-property name="orderNumber" 
>> type="java.lang.Integer" />
>>                <form-property name="customerName" 
>> type="java.lang.String" />
>>                <form-property name="orderValue" 
>> type="java.lang.BigDecimal" />
>>                <form-property name="orderLines"
>> type="org.apache.commons.beanutils.LazyDynaBean[]" />
>>            </form-bean>
>>        </form-beans>
>>     </struts-config>
>>
>>
>>
>>
>>
>> -- 
>> Rick
> 
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today - it's 
> FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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


Re: DynaValidatorForm and nested tags.

Posted by fea jabi <zy...@hotmail.com>.
I was under the imporession that something like this should work

<form-bean name="Form1" type="org.apache.struts.action.DynaActionForm" 
dynamic="true">
         <form-property name="property1" type="java.lang.Integer"/>
         <form-property name="property2" type="java.lang.Integer"/>
</form-bean>

<form-bean name="Form2" type="org.apache.struts.validator.DynaValidatorForm" 
dynamic="true">
         <form-property name="hrs" type="Form1"/>
        <form-property name="property3" type="java.lang.Integer"/>
......................
...................
....................
</form-bean>

can't we do this?


>From: Rick Reumann <ri...@gmail.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: Struts Users Mailing List <us...@struts.apache.org>
>Subject: Re: DynaValidatorForm and nested tags.
>Date: Mon, 19 Dec 2005 20:25:54 -0500
>
>On 12/19/05, fea jabi <zy...@hotmail.com> wrote:
> >
> > Thanks. I sure can see the difference.
> >
> > can we use a DynaValidatorForm as an attribute in another
> > DynaValidatorForm?
>
>
>
>I'm guessing you could just simply nest DynaValidatorForms (but I'm sure
>you'll want to use 'Lazy' ones otherwise you'll have some problems when the
>form submits - indexOutOfBoundsExceptions), but I think it might be cleaner
>to just nest a LazyDynaBean as a property of your LazyDynaForm. Others on
>this List have much more experience working with DynaBeans/Forms than me, 
>so
>they might have better suggestions.
>
>More about it here:
>http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html
>
>Notice on that page at the end...
>
><struts-config>
>
>        <form-beans>
>            <form-bean name="restrictedForm"
>type="org.apache.struts.validator.LazyValidatorForm">
>                *<set-property property="restricted" value="true"/>*
>                <form-property name="orderNumber" type="java.lang.Integer" 
>/>
>                <form-property name="customerName" type="java.lang.String" 
>/>
>                <form-property name="orderValue" 
>type="java.lang.BigDecimal" />
>                <form-property name="orderLines"
>type="org.apache.commons.beanutils.LazyDynaBean[]" />
>            </form-bean>
>        </form-beans>
>     </struts-config>
>
>
>
>
>
>--
>Rick

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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


Re: DynaValidatorForm and nested tags.

Posted by Rick Reumann <ri...@gmail.com>.
On 12/19/05, fea jabi <zy...@hotmail.com> wrote:
>
> Thanks. I sure can see the difference.
>
> can we use a DynaValidatorForm as an attribute in another
> DynaValidatorForm?



I'm guessing you could just simply nest DynaValidatorForms (but I'm sure
you'll want to use 'Lazy' ones otherwise you'll have some problems when the
form submits - indexOutOfBoundsExceptions), but I think it might be cleaner
to just nest a LazyDynaBean as a property of your LazyDynaForm. Others on
this List have much more experience working with DynaBeans/Forms than me, so
they might have better suggestions.

More about it here:
http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html

Notice on that page at the end...

<struts-config>

       <form-beans>
           <form-bean name="restrictedForm"
type="org.apache.struts.validator.LazyValidatorForm">
               *<set-property property="restricted" value="true"/>*
               <form-property name="orderNumber" type="java.lang.Integer" />
               <form-property name="customerName" type="java.lang.String" />
               <form-property name="orderValue" type="java.lang.BigDecimal" />
               <form-property name="orderLines"
type="org.apache.commons.beanutils.LazyDynaBean[]" />
           </form-bean>
       </form-beans>
    </struts-config>





--
Rick

Re: DynaValidatorForm and nested tags.

Posted by Rick Reumann <ri...@gmail.com>.
Slight correction to above (copy and past problems when trying to make it
generic):

<c:forEach items="${yourForm.listOf_A_Beans}" var="beanA"
varStatus="beanAlistStatus">
    <html:text property="listOf_A_Beans[${beanAlistStatus.index}].someProperty"
value="${beanA.someProperty}" /><br>
    <c:forEach items="${beanA.listOf_B_Beans}" var="beanB"
varStatus="beanBlistStatus">
       <html:text property="listOf_A_Beans[${beanAlistStatus.index
}].listOf_B_Beans[${beanBlistStatus.index}].someProperty" value="${
beanB.someProperty}" /><br>
    </c:forEach>
</c:forEach>

<nested:iterate property="listOf_A_Beans">
    <nested:text property="someProperty" /><br>
    <nested:iterate property="listOf_B_Beans">
       <nested:text property="someProperty" /><br>
    </nested:iterate>
</nested:iterate>

On 12/19/05, Rick Reumann <ri...@gmail.com> wrote:
>
> On 12/19/05, fea jabi <zy...@hotmail.com> wrote:
> >
> >
> >
> > Also, when exactly do we have to use the nested tags?
>
>
>
> You don't have to use them, but they make things easier/cleaner when you
> need to display fields that are updatable that are nested. For example here
> are two ways.. one with JSTL and one with nested (I think you'd agree the
> second syntax is easier to read).
>
> <c:forEach items="${yourForm.listOf_A_Beans}" var="beanA"
> varStatus="beanAlistStatus">
>     <html:text property="listOf_A_Beans[${beanAlistStatus.index}].someProperty"
> value="${ beanA.someProperty}" /><br>
>     <c:forEach items="${beanA.listOf_B_Beans}" var="beanB"
> varStatus="beanBlistStatus">
>        <html:text property="listOf_A_Beans[${ beanAlistStatus.index
> }].listOf_B_Beans[${beanBlistStatus.index}].name" value="${
> beanB.someProperty}" /><br>
>     </c:forEach>
> </c:forEach>
>
> <nested:iterate property="listOf_A_Beans">
>     <nested:text property="someProperty" /><br>
>     <nested:iterate property="listOf_B_Beans">
>        <nested:text property="someProperty" /><br>
>     </nested:iterate>
> </nested:iterate>
>
>



--
Rick

Re: DynaValidatorForm and nested tags.

Posted by fea jabi <zy...@hotmail.com>.
Thanks. I sure can see the difference.

can we use a DynaValidatorForm as an attribute in another DynaValidatorForm?

Thanks.


>From: Rick Reumann <ri...@gmail.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: Struts Users Mailing List <us...@struts.apache.org>
>Subject: Re: DynaValidatorForm and nested tags.
>Date: Mon, 19 Dec 2005 14:47:35 -0500
>
>On 12/19/05, fea jabi <zy...@hotmail.com> wrote:
> >
> >
> >
> > Also, when exactly do we have to use the nested tags?
>
>
>
>You don't have to use them, but they make things easier/cleaner when you
>need to display fields that are updatable that are nested. For example here
>are two ways.. one with JSTL and one with nested (I think you'd agree the
>second syntax is easier to read).
>
><c:forEach items="${yourForm.listOf_A_Beans}" var="beanA"
>varStatus="beanAlistStatus">
>     <html:text 
>property="listOf_A_Beans[${beanAlistStatus.index}].someProperty"
>value="${beanA.someProperty}" /><br>
>     <c:forEach items="${beanA.listOf_B_Beans}" var="beanB"
>varStatus="beanBlistStatus">
>        <html:text property="listOf_A_Beans[${beanAlistStatus.index
>}].listOf_B_Beans[${beanBlistStatus.index}].name" value="${
>beanB.someProperty}" /><br>
>     </c:forEach>
></c:forEach>
>
><nested:iterate property="listOf_A_Beans">
>     <nested:text property="someProperty" /><br>
>     <nested:iterate property="listOf_B_Beans">
>        <nested:text property="someProperty" /><br>
>     </nested:iterate>
></nested:iterate>

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


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


Re: DynaValidatorForm and nested tags.

Posted by Rick Reumann <ri...@gmail.com>.
On 12/19/05, fea jabi <zy...@hotmail.com> wrote:
>
>
>
> Also, when exactly do we have to use the nested tags?



You don't have to use them, but they make things easier/cleaner when you
need to display fields that are updatable that are nested. For example here
are two ways.. one with JSTL and one with nested (I think you'd agree the
second syntax is easier to read).

<c:forEach items="${yourForm.listOf_A_Beans}" var="beanA"
varStatus="beanAlistStatus">
    <html:text property="listOf_A_Beans[${beanAlistStatus.index}].someProperty"
value="${beanA.someProperty}" /><br>
    <c:forEach items="${beanA.listOf_B_Beans}" var="beanB"
varStatus="beanBlistStatus">
       <html:text property="listOf_A_Beans[${beanAlistStatus.index
}].listOf_B_Beans[${beanBlistStatus.index}].name" value="${
beanB.someProperty}" /><br>
    </c:forEach>
</c:forEach>

<nested:iterate property="listOf_A_Beans">
    <nested:text property="someProperty" /><br>
    <nested:iterate property="listOf_B_Beans">
       <nested:text property="someProperty" /><br>
    </nested:iterate>
</nested:iterate>