我有使用弹簧幅流Java Web应用程序。

如何传递值从一个流至另一个流?

<?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>

我有这里的编辑功能的问题。在我的编辑页面我的用户名,旧密码,新密码和确认密码字段。

首先,在validateAccount状态I检查,如果用户名和旧密码存在于数据库中,如果它不存在它它我转发给queryall状态。

如果它存在我是否新密码和confirmpassword值是相同的,如果它们是相同的我继续进行编辑。

如果不是我再次回到queryAll。

QueryAll状态获取用户的权限时重新显示所述网页来填充它的形式。当我离开密码领域的空白,并在第一时间我点击编辑按钮时,它抛出一个显示java.lang.NullPointerException。

有帮助吗?

解决方案

创建两个流作为子流,然后在每个流中的数据应该在父和子流等可用。

  

将数据映射到子流发生   前子流会话启动。   从子流回到映射数据   父流程完成时   子流程完成和父流   会话恢复。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top