you want to use the class name rather property name on your conversion file.  

com.mydomain.model.Artist=com.mydomain.converter.ArtistConverter

You specify the property name when telling struts the Bean type for an
entire collection.  I don't think you can register Type Converters for a
particular instance of a Type  in that request.  I see you are trying to
transform the Various Artists from some variants.  You could create a
special class for this property so you can use type conversion but that
seems ugly.

You are better off using EL or a custom tag for rendering the property.  You
have more of a formatting issue than actual Type Conversion that moves
values back and forth between different types.

Marsman wrote:
> 
> Hi!
> 
> I got a List with some beans and want to convert values of the bean
> properties before they are shown by the s:property tag. Like I know it
> from JSF I want to use a struts type converter. But neither the action nor
> the global defined converter was called by the framework. Here are some
> code-snippets:
> 
> <s:iterator value="albums">
>   <s:property value="artist"/>
> </s:iterator>
> 
> artist=domain.music.converter.ArtistConverter
> 
> public class ArtistConverter extends StrutsTypeConverter {
> 
>   @Override
>   public Object convertFromString(Map context, String[] values, Class
> toClass) {
>     if (values[0] == null || values[0].length() == 0 &&
> values[0].equalsIgnoreCase("v.a.")
>         || values[0].equalsIgnoreCase("various artists"))
>       return null;
>     else
>       return values[0];
>   }
> 
>   @Override
>   public String convertToString(Map context, Object o) {
>     if (o == null)
>       return "Various Artists";
>     else
>       return (String) o;
>   }
> }
> 
> I'm not sure beeing on the right way. Maybe converters can only be defined
> for form fields? Or not for properties of an iteration?
> 
> Titus
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Struts-2-Type-Conversion-for-properties-of-a-List-tp21144957p21153560.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to