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 getters but 
no setters.
Input masks use these lookup objects in select lists, e.g. 
<s:select
   id="foo"
   name="person.country.id"
   list="countries"
   listKey="id"
   listValue="description"
   headerKey="-1"
   headerValue=" --- Please select country --- "
   cssStyle="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="person.country" and listKey="this" -> problem the other way 
around: No match when entering the mask with existing data, after selecting 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 
implemented interfaces
        Class curClazz = 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: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to