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-tp21144957p21144957.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