All,

The type converter interface has the validation errors as an argument.  If 
invalid input is contained in the post, the collection is there to add a new 
error message to.   But to add a useful error message, I need the field name as 
a parameter.   Which I'm not able to get (unless I am missing something?)

public Object convert(String input, Class<? extends Object> type,
            Collection<ValidationError> errors) {
      Object result = null;
      if (input == null) {
            // The value supplied ({1}) for field {0} is invalid
            errors.add(new LocalizableError(
                        "validation.expression.valueFailedExpression",
                        input, "how do I get the field name?"));
      } else {
            result = new Object();
      }
      return result;
}

Am I missing something?  Shouldn't the interface be

public Object convert(String fieldName, String input,
            Class<? extends Object> type,
            Collection<ValidationError> errors) {

Or maybe even

public <T, A extends ActionBean> convert(A actionBean, String fieldName, String 
input,
            Class<? extends T> type,
            Collection<ValidationError> errors) {

I think it would be nice to get the current action bean instance in there, 
allowing access through to the session etc.  Essentially what I'm getting at is 
the type converters could make use of a lot more stuff than they currently get. 
 I could do some workaround with spring to control these instances and inject 
the current bean and other stuff in there, but it would be much easier if the 
public method just got other things as a parameter.

Thoughts?
-John
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to