I have added a validation in my flow and it works fine, the only problem is I am not able to execute my action class method after the validation. If I remove the validation it works fine.
Here is what my flow.xml looks like
<view-state id="myView" view="newView" model="viewModel">
<transition on="doChangeView" to="doChangeView" />
<transition on="done" to="home" validate="false" />
</view-state>
<action-state id="doChangeView">
<evaluate expression="viewAction.doChangeView" />
<transition on="done" to="home" />
</action-state>
I am guessing that I am not setting the flow correctly. Any help will be appreciated.
In my case, after looking through logs I found that there was some error in the validation method. After resolving it I was able to execute the method in my action class.
Related
I am creating a ShoppingCart Application in Spring mvc.Here I have two flows for now.
Registration Flow(flow id=registrationFlow)
MailSender Flow(flow id=mailFlow)
When user registration data gets entered in DB successfully a mailSender flow(Subflow) will get triggered.
My Parent Flow is RegistrationFlow.
Please find below Subflow invocation code:
<!-- other navigation rules of parent flow -->
<subflow-state id="mailSenderFlow" subflow="mailFlow">
<input name="userEmail" value="flowScope.regBean.userDTO.userMail"/>
<transition on="finishMailFlow" to="checkMailFlowResult" />
</subflow-state>
<decision-state id="checkMailFlowResult">
<if test="mailSender.mailConfirmation(currentEvent.attributes.mailFlowOutcome)"
then="regSuccess" else="regConfirm" />
</decision-state>
<end-state id="regSuccess" view="/WEB-INF/view/regSuccess.jsp" />
Based on subflow outcome I have created a decision state which will take the control to regSuccess page or back to regConfirm page.
Please find below Subflow definition file:
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.4.xsd">
<input name="userEmail" required="true" type="java.lang.String"/>
<action-state id="mailSenderAction">
<evaluate expression="mailSender.sendEmail(userEmail)" />
<transition on="success" to="finishMailFlow" />
</action-state>
<end-state id="finishMailFlow">
<output name="mailFlowOutcome" value="mail sending done"/>
</end-state>
</flow>
Now during subflow invocation time I am getting following exception :
org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'mailSenderFlow' of flow 'registrationFlow'
at org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:573)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:253)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.expression.spel.SpelParseException: EL1041E: After parsing a valid expression, there is still more data in the expression: 'sending'
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.doParseExpression(InternalSpelExpressionParser.java:130)
at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:60)
at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:32)
at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:73)
at org.springframework.binding.expression.spel.SpringELExpressionParser.parseSpelExpression(SpringELExpressionParser.java:96)
Truncated. see log file for complete stacktrace>
Can anyone figure out the issue???
try with single quote inside your value:
<output name="mailFlowOutcome" value="'mail sending done'"/>
I have a very basic flow which looks like this :
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:faces="http://www.springframework.org/schema/faces"
xsi:schemaLocation="
http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<view-state id="gestionParametres" view="gestionParametres.xhtml">
<on-entry>
<evaluate expression="gestionParametresAction.initialiser()" />
</on-entry>
<transition on="annulerParametres">
<evaluate expression="gestionParametresAction.annulerParametres()"/>
</transition>
<transition on="enregistrerParametres">
<evaluate expression="gestionParametresAction.enregistrerParametres()"/>
</transition>
<!-- More transitions -->
</view-state>
<end-state id="back"/>
</flow>
Now when I render my page from two different navigators, a change in one page will provoke the same change in the other page. So I want to implement a mechanism that allow my flow to handle concurrent access. How can I achieve that ? I read the spring web flow documentation but I saw nothing about it. May be I am not looking in the right direction...
Thank you.
I solved it using the annotation #Scope("session") on my bean. Obviously the default scope with Spring is #Scope("singleton"), so if I understand correctly, the same instance of the bean was used for every flow using the bean. Here is an other thread that helped me.
I have two projects in my workspace: projectA, projectB. The web-flow of projectA has got the following:
<view-state id="hello" view="projectA/firstJSP" >
</view-state>
<action-state id="checkingvalues">
<evaluate expression="somethingIsthere" />
<transition on="success" to="hello" />
<transition on="error" to="bye" />
</action-state>
Its all working fine. The thing is:
if I add the following to the projectA'flow.xml then, it is not working
<view-state id="bye" view="projectB/someJSP" >
</view-state>
Here, someJSP.jsp is in projectB(path is:/projectB/WebContent/WEB-INF/common/files/someJSP.jsp)
and firstJSP.jsp is in projectA(path is:/projectA/WebContent/WEB-INF/common/gifts/firstJSP.jsp)
So is it possible to call projectB's jsp in projectA's web.xml?
No it is not allowed. At the end everything (classes, jps, htmls ..) is packed into a war file that is separated from other wars.
This should be possible.
See some examples here:
http://www.jonathanhui.com/spring-web-flow-web-flow-definiation
In your case you probably want to use something like the following:
<view-state id="bye"
view="externalRedirect:serverRelative:projectB/someJSP">
Although as I guess you would want to end the flow at this point then the following might be better:
<action-state id="checkingvalues">
<evaluate expression="somethingIsthere" />
<transition on="success" to="hello" />
<transition on="error" to="bye" />
</action-state>
<end-state id="bye" view="externalRedirect:serverRelative:projectB/someJSP"/>
My application uses CAS 3.4.11, Spring 3.1 and Hibernate 4.
My login-webflow.xml uses spring-webflow-2.0.xsd and the login flow is given below,
<var name="credentials" class="org.jasig.cas.authentication.principal.UsernamePasswordCredentials" />
<on-start>
<evaluate expression="initialFlowSetupAction" />
</on-start>
<view-state id="viewLoginForm" view="casLoginView" model="credentials">
<binder>
<binding property="username" />
<binding property="password" />
</binder>
<on-entry>
<set name="viewScope.commandName" value="'credentials'" />
</on-entry>
<transition on="submit" bind="true" validate="true" to="realSubmit">
<evaluate expression="authenticationViaFormAction.doBind(flowRequestContext, flowScope.credentials)" />
</transition>
</view-state>
The beans "initialFlowSetupAction" and "authenticationViaFormAction" are defined in cas-servlet.xml as,
<bean id="initialFlowSetupAction" class="org.jasig.cas.web.flow.InitialFlowSetupAction"
p:argumentExtractors-ref="argumentExtractors"
p:warnCookieGenerator-ref="warnCookieGenerator"
p:ticketGrantingTicketCookieGenerator-ref="ticketGrantingTicketCookieGenerator"/>
<bean id="authenticationViaFormAction" class="org.jasig.cas.web.flow.AuthenticationViaFormAction"
p:centralAuthenticationService-ref="centralAuthenticationService"
p:warnCookieGenerator-ref="warnCookieGenerator"/>
The issue here is, the InitialFlowSetupAction is called while launch the login page. On click of "Sign In" button the bind/submit method of AuthenticationViaFormAction class should be invoked. But always the InitialFlowSetupAction is called and the form is redisplayed with out any exception. Atleast I could track if there is an exception.
Can it be a binding issue with username and password fields of the form to set its properties to UsernamePasswordCredentials?
Basically I would like to know why InitialFlowSetupAction is invoked onclick of "Sign In" button?
Probably it is because your form does not hold value of "_flowExecutionKey" field.
It should contain next input elements to be able to resume flow execution.
<form>
...
<input type="hidden" name="_eventId" value="submit" />
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}" />
</form>
http://static.springsource.org/spring-webflow/docs/2.0-m1/reference/flow-executor.html
In CAS 3.5.2 for some reason field "execution" is used instead of "_flowExecutionKey".
Try setting validate to false:
<transition on="submit" bind="true" validate="false" to="realSubmit">
I'm setting up an application using Spring Webflow 2, and I'm running into a problem. The app takes in a reservation on one page and then allows for payment on another page. The reservation model object works fine; I can fill out the form, submit it, and it shows the fully populated object on the following confirmation screen. When I do the same thing with the paymentInformation model object however, none of the form's contents are bound into the model object when it is processed.
Here's my flow definition. (I moved the payment flow into a subflow while I was trying to troubleshoot this problem.)
<?xml version="1.0" encoding="UTF-8"?>
<flow
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/webflow"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<var name="paymentInfo" class="com.myapp.payments.domain.PaymentInfo" />
<input name="reservation" />
<decision-state id="paymentDecision">
<if test="reservationServiceImpl.needsPayment(reservation)"
then="enterPayment"
else="resolvePayment" />
</decision-state>
<view-state id="enterPayment" view="enterPayment" model="paymentInfo">
<on-render>
<evaluate expression="reservationMultiAction.preparePayment" />
<set name="viewScope.stepNumber" value="3" />
</on-render>
<transition on="back" to="editReservation" />
<transition on="submitPayment" to="resolvePayment" />
</view-state>
<action-state id="resolvePayment">
<evaluate expression="reservationMultiAction.submitPayment" />
<transition on="success" to="receipt" />
<transition on="failure" to="payment" />
</action-state>
<end-state id="editReservation" />
<end-state id="receipt" />
</flow>
Calling preparePayment populates the bean in the flowScope, and then correctly populates the form on the enterPayment page. But when I debug the submitPayment action method, the paymentInfo bean only has the results of preparePayment, and nothing from the submitted form.
And since I'm sure someone will ask, here's the opening form tag from the enterPayment page:
<form:form modelAttribute="paymentInfo" method="post">
It is hard to identify the error if full form html code is not included. At first sight, it could be a missing action attribute in the form tag.
<form:form action="${flowExecutionUrl}" modelAttribute="paymentInfo" method="post">
<input type="submit" id="_eventId" value="submitPayment" />
</form:form>