struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <lukaszlen...@apache.org>
Subject Re: Not calling setters when callchaining into fields and using complex type, bug or feature?
Date Fri, 04 Apr 2014 06:58:31 GMT
You mean in EnumTypeConverter? Or in DefaultTypeConverter?

2014-04-04 8:47 GMT+02:00 Fabian Richter <frichter@mtg.de>:
> Yeah, I was having Converters for both types, AND DifferentComplexType is an
> enum.
>
> The problem was, in the converters convertFromString method the
> enum.valueOf() should have thrown an IllegalArgumentException when calling
> it with an emtpy String "" but instead, just the conversion silently failed
> and the value didnt get set.
>
> Not sure this is "as designed" thats up to you guys, but I solved it by
> handling "" explicitly.
>
> Thanks for your support!
>
> Am 04.04.2014 07:16, schrieb Lukasz Lenart:
>>
>> Do you have converters for ComplexType and DifferentComplexType
>> registered?
>>
>> 2014-04-03 11:19 GMT+02:00 Fabian Richter <frichter@mtg.de>:
>>>
>>> Hey,
>>>
>>> not sure this is a Bug or a Feature, but I ran into the following
>>> troubles,
>>> someone might be able to explain:
>>>
>>> class ComplexType {
>>>          private DifferentComplexType test;
>>>
>>>          public void setTest(DifferentComplexType test){
>>>                  this.test = test;
>>>          }
>>>          public DifferentComplexType getTest(){
>>>                  return this.test;
>>>          }
>>> }
>>>
>>> In an action class I have
>>>
>>>          private ComplexType field;
>>>
>>>          public ComplexType getField(){
>>>                  return this.field;
>>>          }
>>>
>>>          public void setField(ComplexType field){
>>>                  this.field = field;
>>>          }
>>>
>>> Now in this Action, I am setting "test" with a <s:select list="..."
>>> key="field.test" headerKey="" headerValue="Undefined" />
>>>
>>> But when I want to null it, by selecting the header entry "Undefined",
>>> Struts is not calling getField().setTest() its not changing "test" in
>>> "field" at all.
>>>
>>> When I add to my action
>>>
>>>          public DifferentComplexType getTest(){
>>>                  return this.field.getTest();
>>>          }
>>>
>>>          public void setTest(DifferentComplexType test){
>>>                  this.field.setTest(test);
>>>          }
>>>
>>> and change the <s:select> to use key="test" it works like a charm.
>>>
>>> Is that how its supposed to be? If so, why?
>>>
>>> Thank you for explaining!
>>>
>>> Best
>>> Fabian
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
> --
> media transfer AG
>
> Fabian Richter, M.Sc.
> Softwareentwickler
>
> Mail:    frichter@mtg.de
> Telefon: +49 6151 8193-24
> Telefax: +49 6151 8193-43
> Web:     http://www.mtg.de
>
> Firmensitz: Dolivostraße 11, 64293 Darmstadt
> Registergericht: Amtsgericht Darmstadt, HRB 8901
> Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz
> Aufsichtsratsvorsitzender: Dr. Thomas Milde
>

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


Mime
View raw message