views:

533

answers:

1

I have a java web applicaitonj. using spring web flow. How do I pass values from one flow to another flow

http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

<persistence-context />

<var name="editBean" class="jp.co.anicom.domain.User" />
<var name="deleteBean" class="jp.co.anicom.domain.User" />
<var name="authorityBean" class="jp.co.anicom.domain.Authority" />


<on-start>
 <set name="flowScope.username" value="requestParameters.username" />
</on-start>

<action-state id="queryAll">
 <evaluate expression="employeeAction.GetAuthority(flowScope.username)"
  result="authorityBean" />
 <transition to="editForm" />
</action-state>

<view-state id="editForm" model="editBean" view="../xhtml/framework/edit">
 <transition on="editButton" to="validateAccount" />
 <transition on="delete" to="getId" />
 <transition on="back" to="editSuccessful" />
</view-state>

<action-state id="validateAccount">
 <evaluate expression="employeeAction.GetEmployee(flowScope.username, oldPassword)"
  result="editBean" />
 <transition to="checkUserAccount" />
</action-state>

<action-state id="getId">
 <evaluate expression="employeeAction.GetEmployee(flowScope.username)"
  result="deleteBean" />
 <transition to="deleteUser" />
</action-state>

<decision-state id="checkUserAccount">
 <if test="editBean == null" then="queryAll"
  else="confirmPassword" />
</decision-state>

<decision-state id="confirmPassword">
 <if test="newPassword.equals(confirmPassword)" then="editUser1"
  else="queryAll" />
</decision-state>

<action-state id="editUser1">
 <set name="editBean.password" value="newPassword" />
 <transition to="editUser2" />
</action-state>

<action-state id="editUser2">
 <evaluate
  expression="employeeAction.editEmployee(editBean, authorityBean.authority)" />
 <transition to="editSuccessful" />
</action-state>

<action-state id="deleteUser">
 <evaluate expression="employeeAction.deleteEmployee(deleteBean)" />
 <transition to="editSuccessful" />
</action-state>

<end-state id="editSuccessful"
 view="externalRedirect:contextRelative:/admin_main.do" commit="true" />
<end-state id="displayError" view="../xhtml/framework/displayError" />
<end-state id="dummy1" view="../xhtml/framework/dummy" />

<global-transitions>
 <transition on-exception="java.lang.Exception" to="displayError" />
</global-transitions>

I am having a problem with the edit functionality here. In my edit page I have username, oldpassword, newpassword and confirm password fields. First in validateAccount state I check if the username and oldpassword exists in the database. if it it doesn't exists I forward it to queryall state. If it exists I check if the new password and confirmpassword values are the same.If the same I proceed with the editing. If not I return again to queryAll. QueryAll state gets the authority of the user to populate it in the form upon redisplaying the page. When I leave the password fieldS blank and the first time I click edit button It throws a java.lang.NullPointerException .

A: 

Create your two flows as subflows and then the data in each flow should be available in the parent and the other subflows.

There's some relevant information here:

Mapping data to the subflow happens before the subflow session is started. Mapping data from the subflow back to the parent flow is done when the subflow completes and the parent flow session resumes.

Taylor Leese
added something above in my question...
cedric