...
It is possible to extend the NameBasedActionResolver to modify the rules used to generate the URL bindings. Changing the set of packages or the suffix used is trivial. For example:
Code Block | ||||
---|---|---|---|---|
| ||||
public class MyActionResolver extends NameBasedActionResolver { @Override public Set<String> getBasePackages() { return Literal.set("ui", "client"); } @Override public String getBindingSuffix() { return ".do"; /* ugh */ } } |
...
Now, if you created your own TypeConverter you could use it by attaching a single annotation to your property:
Code Block | ||
---|---|---|
| ||
@Validate(converter=MoneyTypeConverter.class) private Money balance; |
But that's sub-optimal! This might seem like the easy route, but when you start using the same Money
class in lots of actions you'll have to keep repeating this. Instead you could create your own custom TypeConverterFactory. This will make Stripes aware of the Money
type so that it will automatically convert it whenever it sees it. The easiest way to do this is to extend the built in DefaultTypeConverterFactory, for example:
Code Block | ||||
---|---|---|---|---|
| ||||
public class CustomTypeConverterFactory extends DefaultTypeConverterFactory { public void init(Configuration configuration) { super.init(configuration); add(Money.class, MoneyTypeConverter.class); } } |
...