> One avenue you can explore is to use the formatType= attribute.
> Cheers,
> Freddy
>
Freddy, the "formatType" suggestion did the trick. For anyone else that may
have this same problem, here's my solution:
public class FooFormatter implements Formatter<Foo>{
private static List<String> VALID_TYPES =
Collections.unmodifiableList(
Arrays.asList( new String[] { "id", "name" } )
);
private String formatType;
public void setFormatType( String formatType ) {
this.formatType = formatType;
}
public void init() {
/*
* If the user doesn't specify a format type, or specifies an
* unrecognized one, then we fall back on "id".
*/
if ( this.formatType == null ||
!VALID_TYPES.contains( this.formatType )) {
this.formatType = "id";
}
}
public void setFormatPattern(String theFormatPattern) { }
public void setLocale(Locale theLocale) { }
public String format( Foo input ) {
String returnValue = null;
if ( "id".equals( this.formatType )) {
returnValue = input.getId().toString();
}
else if ( "name".equals( this.formatType )) {
returnValue = input.getName();
}
return returnValue;
}
}
Now I can use something like the following:
<stripes:text name="bar.foo" formatType="name"/>
and the appropriate code in my Formatter will get called. Leaving the
formatType attribute off will result in my old, id-based behavior being
invoked in the Formatter.
Thanks Freddy for pointing me in the right direction. I knew there had to
be a more Stripey way to do what I wanted :)
Chris
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users