Struts7: Select lists for nested objects with lookup objects

Ute Kaiser <[email protected]> Thu, 11 Sep 2025 15:12:59 +0000
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <trinity-b7864df5-c861-44f5-8541-496228add12d-1757603579320@trinity-msg-rest-webde-webde-live-547b7479bd-r2ngd>
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.=20
<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 s=
aving 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 impl=
emented 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