You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurie Harper <la...@holoweb.net> on 2005/06/08 04:26:56 UTC
Nested properties in DynaActionForm
I'm probably missing something really obvious but I've been fiddling
about with this for a while now. Maybe someone can spot what I'm doing
wrong...
I'm using DynaActionForms in my Struts app and I'd like to be able to
reference a property like this:
<html:text property="iterationLength.time"/>
I tried a form declaration like this:
<form name="...">
<form-property name="iterationLength.time" type="java.lang.String"/>
</form>
but I get an error during request processing that 'iterationLength' is
not a valid property. So then I tried:
<form name="...">
<form-property name="prop1" type="java.util.HashMap"/>
</form>
Struts appears to be trying to cope with this:
DEBUG [http8080-Processor24] org.apache.commons.beanutils.BeanUtils -
setProperty(DynaActionForm[dynaClass=ProjectEdit,startDate=,owner=,mode=,description=,iterationLength={},endDate=,status=,name=,doSave=],
iterationLength.time, [1])
DEBUG [http8080-Processor24] org.apache.commons.beanutils.BeanUtils -
Target bean = {}
DEBUG [http8080-Processor24] org.apache.commons.beanutils.BeanUtils -
Target name = time
So it's getting the empty map as the target bean on which to set a
property 'time'. But when I fetch the map from the form in my action,
it's empty.
Is there a way to do this? The reason I want to be able to write the
property as "iterationLength.time", rather than collapsing it to
'iterationLengthTime' or something is for consistency with when I'm
accesing the same property in other beans which aren't dynamically
generated.
Thanks,
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Nested properties in DynaActionForm
Posted by Laurie Harper <la...@holoweb.net>.
But I set up iterationLength as a HashMap; I thought BeanUtils could
handle maps, so it'd do getIterationLength.get("time"). Perhaps I'm
mixing up BeanUtils and JSTL semantics.
L.
Hubert Rabago wrote:
> Nested properties with DynaActionForms actually require you to nest
> objects. :) Using a property name like "iterationLength.time" would
> be like saying "getIterationLength().getTime()", and this is what
> BeanUtils would try to do.
>
> Hubert
>
> On 6/7/05, Laurie Harper <la...@holoweb.net> wrote:
>
>>I'm probably missing something really obvious but I've been fiddling
>>about with this for a while now. Maybe someone can spot what I'm doing
>>wrong...
>>
>>I'm using DynaActionForms in my Struts app and I'd like to be able to
>>reference a property like this:
>>
>> <html:text property="iterationLength.time"/>
>>
>>I tried a form declaration like this:
>>
>> <form name="...">
>> <form-property name="iterationLength.time" type="java.lang.String"/>
>> </form>
>>
>>but I get an error during request processing that 'iterationLength' is
>>not a valid property. So then I tried:
>>
>> <form name="...">
>> <form-property name="prop1" type="java.util.HashMap"/>
>> </form>
>>
>>Struts appears to be trying to cope with this:
>>
>>DEBUG [http8080-Processor24] org.apache.commons.beanutils.BeanUtils -
>>setProperty(DynaActionForm[dynaClass=ProjectEdit,startDate=,owner=,mode=,description=,iterationLength={},endDate=,status=,name=,doSave=],
>>iterationLength.time, [1])
>>DEBUG [http8080-Processor24] org.apache.commons.beanutils.BeanUtils -
>> Target bean = {}
>>DEBUG [http8080-Processor24] org.apache.commons.beanutils.BeanUtils -
>> Target name = time
>>
>>So it's getting the empty map as the target bean on which to set a
>>property 'time'. But when I fetch the map from the form in my action,
>>it's empty.
>>
>>Is there a way to do this? The reason I want to be able to write the
>>property as "iterationLength.time", rather than collapsing it to
>>'iterationLengthTime' or something is for consistency with when I'm
>>accesing the same property in other beans which aren't dynamically
>>generated.
>>
>>Thanks,
>>
>>L.
>>
>>
>>---------------------------------------------------------------------
>>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
Re: Nested properties in DynaActionForm
Posted by Hubert Rabago <hr...@gmail.com>.
Nested properties with DynaActionForms actually require you to nest
objects. :) Using a property name like "iterationLength.time" would
be like saying "getIterationLength().getTime()", and this is what
BeanUtils would try to do.
Hubert
On 6/7/05, Laurie Harper <la...@holoweb.net> wrote:
> I'm probably missing something really obvious but I've been fiddling
> about with this for a while now. Maybe someone can spot what I'm doing
> wrong...
>
> I'm using DynaActionForms in my Struts app and I'd like to be able to
> reference a property like this:
>
> <html:text property="iterationLength.time"/>
>
> I tried a form declaration like this:
>
> <form name="...">
> <form-property name="iterationLength.time" type="java.lang.String"/>
> </form>
>
> but I get an error during request processing that 'iterationLength' is
> not a valid property. So then I tried:
>
> <form name="...">
> <form-property name="prop1" type="java.util.HashMap"/>
> </form>
>
> Struts appears to be trying to cope with this:
>
> DEBUG [http8080-Processor24] org.apache.commons.beanutils.BeanUtils -
> setProperty(DynaActionForm[dynaClass=ProjectEdit,startDate=,owner=,mode=,description=,iterationLength={},endDate=,status=,name=,doSave=],
> iterationLength.time, [1])
> DEBUG [http8080-Processor24] org.apache.commons.beanutils.BeanUtils -
> Target bean = {}
> DEBUG [http8080-Processor24] org.apache.commons.beanutils.BeanUtils -
> Target name = time
>
> So it's getting the empty map as the target bean on which to set a
> property 'time'. But when I fetch the map from the form in my action,
> it's empty.
>
> Is there a way to do this? The reason I want to be able to write the
> property as "iterationLength.time", rather than collapsing it to
> 'iterationLengthTime' or something is for consistency with when I'm
> accesing the same property in other beans which aren't dynamically
> generated.
>
> Thanks,
>
> L.
>
>
> ---------------------------------------------------------------------
> 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