Announcement Announcement Module
Collapse
No announcement yet.
Field Validate in Spring Web Flow Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Field Validate in Spring Web Flow

    Field Validate in Spring Web Flow

    I am trying to do my field validate inside the controller of my Spring Web Flow. I have the following code inside my code and it works great if I have a error but if I dont have a error what do I return? Am I doing this the right why?

    Code in my controller:
    public Event validateVisit(Visit visit, MessageContext messageContext)
    {
    String temp = visit.getType_of_visit() + "";
    if(temp.equals(""))
    {
    MessageBuilder errorMessageBuilder = new MessageBuilder().error();
    errorMessageBuilder.source("type_of_visit");
    errorMessageBuilder.code("type_of_visit_missing");
    messageContext.addMessage(errorMessageBuilder.buil d());
    return new EventFactorySupport().error(this);
    }
    }

    Here is my flow.xml
    <view-state id="SchoolVisitReport" view="SchoolVisitReport.jsp" model="visit">
    <transition on="submit" to="addVisit">
    <evaluate expression="flowActions.validateVisit(visit, messageContext)"/>
    </transition>
    <transition on="cancel" to="endState"/>
    </view-state>

    <decision-state id="addVisit">
    <if test="flowActions.addVisit(visit)" then="endState" else="errorState" />
    </decision-state>

    Please let me know if I am doing this the right what.. I cant get it working if I dont have a error.
Working...
X