Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Validation
-
Labels:None
Description
The canonical example is the ability to have a BigDecimal type converter that will automatically truncate the number down to the required scale. For example, you might want to be able to write something like:
@Validate(converterParams=@Param(name="scale" value="2") BigDecimal dollarAmount;
@Validate(converterParams=@Param(name="scale" value="0") BigDecimal liraAmount;
I don't particularly like the syntax that I've written above, but it would need to be something flexible since each converter make take a different set of parameters. Also, might need to deal with type issues - the parameter above is obviously a number but the value is expressed as a string. Perhaps it could work with:
@Param(name="foo", [numValue=N|stringValue="N"|etc.]?
Also would need to figure out how to make the type converter aware of these parameters. Do we try to inject them using setters? Or just pass across a map of key/value pairs?
It also can be useful to make TypeConverters aware of action bean or actino bean context or any class that can provide access to request/response/servlet context.
For example i need to convert some string to integer depeding on user settings (e.g. from cookies), user input can be inches/foots/millimetres/metres etc.
And having access to servlet context from custom type converter can be very helpful in this case.