History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: EQX-204
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Matt Raible
Reporter: Björn Frantzén
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
AppFuse Light

Validator in UserFormController doesn't work

Created: 04/Nov/08 11:55 AM   Updated: 04/Nov/08 12:56 PM
Component/s: Web - Spring
Affects Version/s: 1.8.2
Fix Version/s: 2.0.0-beta


 Description  « Hide
The code:

@Autowired(required = false)
@Qualifier("beanValidator")
Validator validator;

followed by

if (validator != null)
   setValidator(validator);
}

in the constructor doesn't work. The field validator is always null when instantiating the bean, and the validator field is set after instatiating the object but then it is to late.

Solution:

Add this method

   @Autowired(required = false)
   public void setFormValidator(Validator validator) {
      if (validator != null) {
         setValidator(validator);
      }
   }

and remove the code from the constructor and it should work properly again.


 All   Comments   Change History   FishEye      Sort Order:
Matt Raible - 04/Nov/08 12:44 PM
Thanks for the tip. I recently fixed this with the following patch:

http://source.appfuse.org/browse/appfuse-light/trunk/src/main/java/org/appfuse/web/UserFormController.java?r1=141&r2=142

Notice the following in onSubmit():

    // validation, TODO: Figure out how to do automatically
    validator.validate(command, errors);
    if (errors.getErrorCount() > 0)
        return showForm(request, response, errors);

I like your solution better.