This content has been marked as final.
Show 3 replies
-
1. Re: Validation with pageflows
pmuir Jan 23, 2007 5:29 AM (in response to sonstone)If validation is failing you shouldn't reach the action method.
Post some code! -
2. Re: Validation with pageflows
sonstone Jan 23, 2007 9:29 AM (in response to sonstone)Here is some code:
The beans:@Entity @Name("payment") @Scope(ScopeType.CONVERSATION) public class PaymentBean implements Payment { @NotNull @Length(max=12,min=10) @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; } @Begin(join=true) public void begin() { System.out.println("PaymentBean.begin()"); } } @Name("paymentAction") @Stateful @Scope(ScopeType.CONVERSATION) public class PaymentActionBean implements PaymentAction { @In(create=true) @Valid private Payment payment; @Create @Begin(join=true) public void begin() { System.out.println("PaymentActionBean.begin()"); } @Remove @Destroy public void destroy() { System.out.println("PaymentActionBean.destroy()"); } @IfInvalid(outcome = Outcome.REDISPLAY) public void doAuthenticate() { System.out.println(payment.getAccountNumber()); System.out.println("I am authenticating"); } ... }
Here is the flow:<pageflow-definition name="payment-flow"> <start-page name="authenticate" view-id="/authenticate.jspx"> <redirect/> <transition to="authenticate"> </transition> <transition name="doAuthenticate" to="confirm"> <action expression="#{paymentAction.doAuthenticate}"/> </transition> </start-page> <page name="confirm" view-id="/confirm.jspx"> <redirect/> <transition name="doConfirm" to="transact"> <action expression="#{paymentAction.doConfirm}"/> </transition> </page> <decision name="transact" expression="#{true}"> <transition name="true" to="acknowledge"> <action expression="#{paymentAction.doTransact}"/> </transition> </decision> <page name="acknowledge" view-id="/acknowledge.jspx"> <redirect/> <end-conversation/> </page> </pageflow-definition>
And finally the first page:<?xml version="1.0"?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://jboss.com/products/seam/taglib" xmlns="http://www.w3.org/1999/xhtml" version="2.0"> <jsp:output doctype-root-element="html" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> <jsp:directive.page contentType="text/html"/> <head> <title>Authenticate...</title> </head> <body> <h1>Authenticate...</h1> <f:view> <h:form> <h:messages globalOnly="true"/> <h:outputText value="Enter Account Number:"/> <h:inputText value="#{payment.accountNumber}" id="accountNumber" required="true"> </h:inputText> <s:validateAll/> <h:commandButton value="Ok" action="doAuthenticate"/> <br/> </h:form> </f:view> </body> </jsp:root>
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,
Daniel -
3. Re: Validation with pageflows
sonstone Jan 23, 2007 11:10 AM (in response to sonstone)I figured out what the problem was. I wasn't surrounding the h:inputText tag with the s:validateAll tag.