Re: Struts7: Select lists for nested objects with lookup objects

Lukasz Lenart <[email protected]> Sun, 14 Sep 2025 16:22:59 +0200
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <CAMopvkP4+zNH+6hj=92hC=1dYYL-w1gcwj7PyhZDsfhd+U1JTA@mail.gmail.com>
Did you define a proper struts-conversion.properties?
https://github.com/apache/struts-examples/blob/main/type-conversion/src/mai=
n/resources/struts-conversion.properties

You can review this example for some hints:
https://github.com/apache/struts-examples/tree/main/type-conversion


Cheers
=C5=81ukasz


czw., 11 wrz 2025 o 17:13 Ute Kaiser <[email protected]> napisa=C5=82(a)=
:
>
> Hi,
>
> looking for best practice to use <s:select /> for nested objects.
>
> My application uses a lot of lookup objects for countries, currencies etc=
. loaded from database on startup. They have id and description with getter=
s but no setters.
> Input masks use these lookup objects in select lists, e.g.
> <s:select
>    id=3D"foo"
>    name=3D"person.country.id"
>    list=3D"countries"
>    listKey=3D"id"
>    listValue=3D"description"
>    headerKey=3D"-1"
>    headerValue=3D" --- Please select country --- "
>    cssStyle=3D"width:300px;"
> />
> Class person: Long id, String name, Country country
> That works fine when entering the mask and displaying the data. But when =
saving the data, Struts error: no setId() for country.
> Setting name=3D"person.country" and listKey=3D"this" -> problem the other=
 way around: No match when entering the mask with existing data, after sele=
cting a country and saving, person has the proper country.
>
> I tried https://struts.apache.org/core-developers/type-conversion
> but XWorkConverter does not use my converter.
> Debugging Struts, I see that XWorkConverter.buildConverterMapping decides=
 to ignore my lookup class by converterHolder.addNoMapping(clazz)
> It looks to me that
> // check for conversion mapping associated with super classes and any imp=
lemented interfaces
>         Class curClazz =3D clazz;
>
>         while (!curClazz.equals(Object.class)) {
>             // add current class' mappings
>             addConverterMapping(mapping, curClazz);
> clazz is my lookup class but curClazz is java.lang.object.
>
> I would appreciate to get some advice how to handle my problem.
>
> Best regards Ute
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>