3 Replies Latest reply on Jan 23, 2007 11:10 AM by Daniel Spangler

    Validation with pageflows

    Daniel Spangler Newbie

      How do you get a pageflow to stay on the same page if a validation error occurs?

      I am currently using the s:validateAll tag to initiate the validation within my page. I have an h:commandButton that triggers the transition change. I can see DEBUG statements from the ValidationInterceptor stating that a validation error has occurred, but the page continues to go to the next transition. I have tried adding @IfInvalid(outcome=Outcome.REDISPLAY) to my action but that doesn't seem to do anything.

      Any help would be greatly appreciated.


        • 1. Re: Validation with pageflows
          Pete Muir Master

          If validation is failing you shouldn't reach the action method.

          Post some code!

          • 2. Re: Validation with pageflows
            Daniel Spangler Newbie

            Here is some code:

            The beans:

            public class PaymentBean implements Payment {
             @Pattern(regex="^[a-zA-Z0-9]+$", message="Must be alphanumeric.")
             private String accountNumber;
             public String getAccountNumber() {
             return accountNumber;
             public void setAccountNumber(final String accountNumber) {
             System.out.println("Setting accountNumber to: " + accountNumber);
             this.accountNumber = accountNumber;
             public void begin()
            public class PaymentActionBean implements PaymentAction {
             private Payment payment;
             @Create @Begin(join=true)
             public void begin()
             public void destroy() {
             @IfInvalid(outcome = Outcome.REDISPLAY)
             public void doAuthenticate()
             System.out.println("I am authenticating");

            Here is the flow:
            <pageflow-definition name="payment-flow">
             <start-page name="authenticate" view-id="/authenticate.jspx">
             <transition to="authenticate">
             <transition name="doAuthenticate" to="confirm">
             <action expression="#{paymentAction.doAuthenticate}"/>
             <page name="confirm" view-id="/confirm.jspx">
             <transition name="doConfirm" to="transact">
             <action expression="#{paymentAction.doConfirm}"/>
             <decision name="transact" expression="#{true}">
             <transition name="true" to="acknowledge">
             <action expression="#{paymentAction.doTransact}"/>
             <page name="acknowledge" view-id="/acknowledge.jspx">

            And finally the first page:
            <?xml version="1.0"?>
            <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
             <jsp:output doctype-root-element="html"
             doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
             <jsp:directive.page contentType="text/html"/>
             <h:messages globalOnly="true"/>
             <h:outputText value="Enter Account Number:"/>
             <h:inputText value="#{payment.accountNumber}" id="accountNumber" required="true">
             <h:commandButton value="Ok" action="doAuthenticate"/>

            I see this in the log file but the flow continues to the next page. How can I make it stay on the first page?

            2007-01-23 09:23:31,296 DEBUG [org.jboss.seam.interceptors.ValidationInterceptor] invalid value: accountNumber length must be between 10 and 12
            2007-01-23 09:23:31,296 DEBUG [org.jboss.seam.interceptors.ValidationInterceptor] invalid value: accountNumber Must be alphanumeric.

            Thanks in advance,


            • 3. Re: Validation with pageflows
              Daniel Spangler Newbie

              I figured out what the problem was. I wasn't surrounding the h:inputText tag with the s:validateAll tag.