Announcement Announcement Module
Collapse
No announcement yet.
validator sets error, but error not thrown Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • validator sets error, but error not thrown

    Hi,

    My page has a link to an AbstractCommandController, which has a validator. The link simply contains two 'id' parameters, and the validator checks for their existence. When I don't pass one, it goes into the validator properly, and calls the errors.reject method, but the error is not thrown. It continues into the handle method for the controller.

    Is it because it doesn't know where to post the error to? Here's my sample code:

    In the validator:
    MyForm cmd = (MyForm)command;
    if (cmd.getWriterId() == null || cmd.getWriterId().intValue() == 0) {
    errors.reject("required.writerId", "A writer must be selected before using the Remove feature");
    errors.reject("required.accountId", "An account must be selected before using the Remove feature");
    }

    (Note: I was using ValidationUtils.rejectIfEmpty but took that out, thinking it was the culprit)


    In servlet.xml:
    <bean id="removePublisherWriterCtrl" class="thecom.controller.publishers.RemovePublishe rWriterController">
    <property name="validator">
    <bean class="thecom.controller.publishers.validators.MyF ormValidator" />
    </property>
    </bean>

    Thanks
Working...
X