春のWebフロー:どのように私は1つのフローから別のフローに値を渡すん
-
18-09-2019 - |
質問
私は、春のWebフローを使用してJava Webアプリケーションを持っています。
どのように私は1つのフローから別のフローに値を渡すのですか?
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:c="http://java.sun.com/jsp/jstl/core" 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.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>
</flow>
私はここで編集機能に問題が生じています。私の編集ページでは、私は、ユーザー名、oldpassword、新パスワードを持っているし、パスワードフィールドを確認します。
ユーザ名とoldpasswordがデータベースに存在するならば、それはそれは、私はそれが状態をqueryallを楽しみに存在しない場合は、まずvalidateAccount状態で私は、確認してください。
それは新しいパスワードとconfirmpassword値が同じである場合、私は彼らが同じであれば、私は編集を続行、チェックが存在する場合。
私はqueryAllに再び戻らない場合。
QueryAll状態は、ページを再表示する際の形式でそれを移入するためのユーザーの権限を取得します。私は、パスワードフィールドを空白のままにして初めてI編集ボタンをクリックすると、それはjava.lang.NullPointerExceptionが発生します。
解決
サブフローとしてあなたの二つの流れを作成し、各フローのデータは、親や他のサブフローで利用可能であるべきである。
サブフローへのマッピングデータが起きます サブフローセッションが開始される前に。 バックにサブフローからのマッピングデータ 親の流れが行われたとき サブフロー完了し、親の流れ セッションが再開ます。
所属していません StackOverflow