You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Hardy <ah...@cyberspaceroad.com> on 2008/02/22 18:32:52 UTC
xwork-conversion.properties
I wrote a TypeConverter and configured S2 with xwork-conversion.properties to
use it so:
org.permacode.patternrepo.domain.Market=org.permacode.atomic.web.DomainObjectTypeConverter
as per the wiki.
However, from debugging it looks as though struts is completely ignoring the
TypeConverter and instantiating my Market objects as it needs them from scratch,
for instance with nested objects in my form:
instrument.market.id=13
What am I doing wrong? I use the ParamsInterceptor. Should I be using a
different interceptor?
Thanks
Adam
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: xwork-conversion.properties
Posted by Kedar Choudhary <ke...@helixtechsolutions.com>.
Hi Adam,
Setting param-value instrument.market.id=1 will work something like this
(1) instrument = valueStack.getInstrument()
- as your action class with the topmost object implementing this
method it will result in yourActionClass.getInstrument()
(2) if(instrument == null) {
yourActionClass.setInstrument(new Instrument());
instrument = yourActionClass.getInstrument();
}
- this will be done provided there exists no-argument public
constructor for class Instument.
(3) market = instrument.getMarket();
(4) if(market == null) {
Instrument.setMarket(new Market());
market = instrument.getMarket();
}
- again, this is so if there exists no-argument public constructor for
class Market
(5) market.setId(1)
Setting type converter in xwork-conversion.properties like
org.permacode.patternrepo.domain.Market=org.permacode.atomic.web.DomainObjec
tTypeConverter
tells S2 that
"if you need to convert value of other type (typically String) to an object
of Market class use the provided type converter to do the conversion".
Hope this helps.
Regards,
Kedar
-----Original Message-----
From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com]
Sent: Sunday, February 24, 2008 8:42 PM
To: Struts Users Mailing List
Subject: Re: xwork-conversion.properties
Hi Kedar,
perhaps you could expand upon your statement. What I understand is that the
conversion involves the creation of the object graph based on the incoming
HTTP
param-value pair (e.g. instrument.market.id=1) as follows:
(1) id = new Long(1)
(2) market = new Market()
(3) market.setId(id)
(4) instrument = new Instrument()
(5) instrument.setMarket(market)
In steps (2) and (4), my assumption is that OGNL will call my TypeConverter
which I have registered in xwork-conversion.properties to handle those
classes.
Are you implying that OGNL will only delegate to the TypeConverter when
dealing
with the last name in the parameter string (in my case 'id' which is Long)?
Regards
Adam
Kedar Choudhary on 24/02/08 06:10, wrote:
> There is not type conversion to be done when setting value of
> instrument.market.id.
> S2 will call your type converter if you were setting value of
> instrument.market.
>
> Regards
> Kedar
>
> -----Original Message-----
> From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com]
> Sent: Sunday, February 24, 2008 1:02 AM
> To: Struts Users Mailing List
> Subject: Re: xwork-conversion.properties
>
> Adam Hardy on 22/02/08 17:32, wrote:
>> I wrote a TypeConverter and configured S2 with
>> xwork-conversion.properties to use it so:
>>
>>
>
org.permacode.patternrepo.domain.Market=org.permacode.atomic.web.DomainObjec
> tTypeConverter
>>
>> as per the wiki.
>>
>> However, from debugging it looks as though struts is completely ignoring
>> the TypeConverter and instantiating my Market objects as it needs them
>> from scratch, for instance with nested objects in my form:
>>
>> instrument.market.id=13
>>
>> What am I doing wrong? I use the ParamsInterceptor. Should I be using a
>> different interceptor?
>
> This issue is proving very difficult to solve and so far I haven't been
able
> to
> work out from debugging xwork and ognl what exactly is going wrong.
>
> It appears to be just this action which ignores my TypeConverter. Other
> actions
> are working fine with it. They have no extra config - it is only set in
the
> global xworks-conversion.properties file.
>
> Has anyone else ever come across such a situation?
Re: xwork-conversion.properties
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Hi Kedar,
perhaps you could expand upon your statement. What I understand is that the
conversion involves the creation of the object graph based on the incoming HTTP
param-value pair (e.g. instrument.market.id=1) as follows:
(1) id = new Long(1)
(2) market = new Market()
(3) market.setId(id)
(4) instrument = new Instrument()
(5) instrument.setMarket(market)
In steps (2) and (4), my assumption is that OGNL will call my TypeConverter
which I have registered in xwork-conversion.properties to handle those classes.
Are you implying that OGNL will only delegate to the TypeConverter when dealing
with the last name in the parameter string (in my case 'id' which is Long)?
Regards
Adam
Kedar Choudhary on 24/02/08 06:10, wrote:
> There is not type conversion to be done when setting value of
> instrument.market.id.
> S2 will call your type converter if you were setting value of
> instrument.market.
>
> Regards
> Kedar
>
> -----Original Message-----
> From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com]
> Sent: Sunday, February 24, 2008 1:02 AM
> To: Struts Users Mailing List
> Subject: Re: xwork-conversion.properties
>
> Adam Hardy on 22/02/08 17:32, wrote:
>> I wrote a TypeConverter and configured S2 with
>> xwork-conversion.properties to use it so:
>>
>>
> org.permacode.patternrepo.domain.Market=org.permacode.atomic.web.DomainObjec
> tTypeConverter
>>
>> as per the wiki.
>>
>> However, from debugging it looks as though struts is completely ignoring
>> the TypeConverter and instantiating my Market objects as it needs them
>> from scratch, for instance with nested objects in my form:
>>
>> instrument.market.id=13
>>
>> What am I doing wrong? I use the ParamsInterceptor. Should I be using a
>> different interceptor?
>
> This issue is proving very difficult to solve and so far I haven't been able
> to
> work out from debugging xwork and ognl what exactly is going wrong.
>
> It appears to be just this action which ignores my TypeConverter. Other
> actions
> are working fine with it. They have no extra config - it is only set in the
> global xworks-conversion.properties file.
>
> Has anyone else ever come across such a situation?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: xwork-conversion.properties
Posted by Kedar Choudhary <ke...@helixtechsolutions.com>.
There is not type conversion to be done when setting value of
instrument.market.id.
S2 will call your type converter if you were setting value of
instrument.market.
Regards
Kedar
-----Original Message-----
From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com]
Sent: Sunday, February 24, 2008 1:02 AM
To: Struts Users Mailing List
Subject: Re: xwork-conversion.properties
Adam Hardy on 22/02/08 17:32, wrote:
> I wrote a TypeConverter and configured S2 with
> xwork-conversion.properties to use it so:
>
>
org.permacode.patternrepo.domain.Market=org.permacode.atomic.web.DomainObjec
tTypeConverter
>
>
> as per the wiki.
>
> However, from debugging it looks as though struts is completely ignoring
> the TypeConverter and instantiating my Market objects as it needs them
> from scratch, for instance with nested objects in my form:
>
> instrument.market.id=13
>
> What am I doing wrong? I use the ParamsInterceptor. Should I be using a
> different interceptor?
This issue is proving very difficult to solve and so far I haven't been able
to
work out from debugging xwork and ognl what exactly is going wrong.
It appears to be just this action which ignores my TypeConverter. Other
actions
are working fine with it. They have no extra config - it is only set in the
global xworks-conversion.properties file.
Has anyone else ever come across such a situation?
Adam
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: xwork-conversion.properties
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Adam Hardy on 22/02/08 17:32, wrote:
> I wrote a TypeConverter and configured S2 with
> xwork-conversion.properties to use it so:
>
> org.permacode.patternrepo.domain.Market=org.permacode.atomic.web.DomainObjectTypeConverter
>
>
> as per the wiki.
>
> However, from debugging it looks as though struts is completely ignoring
> the TypeConverter and instantiating my Market objects as it needs them
> from scratch, for instance with nested objects in my form:
>
> instrument.market.id=13
>
> What am I doing wrong? I use the ParamsInterceptor. Should I be using a
> different interceptor?
This issue is proving very difficult to solve and so far I haven't been able to
work out from debugging xwork and ognl what exactly is going wrong.
It appears to be just this action which ignores my TypeConverter. Other actions
are working fine with it. They have no extra config - it is only set in the
global xworks-conversion.properties file.
Has anyone else ever come across such a situation?
Adam
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org