Ajax + Spring Webflow



首先,我使用Spring webflow和一些Spring javascript来简化ajax调用。

截至目前,我正在让 ajax 调用 webflow 以显示适当的片段。

所以我正在尝试使用 Spring.AjaxEventDecoration 来满足我的应用程序的 ajax 需求。但是,我在使用此方法和 webflow 时遇到了一些麻烦,据我所知,可以使用的示例很少。

附带说明一下,我没有使用表单或选择框。我想我会提到这一点,因为我找到的每个示例都使用了带有 onlick 事件的表单/表单提交或带有 onchange 事件的选择框。

主要问题:如果我的 webflow 中有一个方法具有来自我的 ajax 的参数,我真的可以将参数从 ajax 传递到 webflow 吗?

法典:

<transition on="disassociateProperty" >
     <evaluate expression="dService.disassociateProperty(requestParameters.currentPId ,currentD)"  result="flowScope.currentD" />
<render fragments="PList" />
</transition>

因此,当我查看firebug中的ajax调用时,它具有我传入的参数(currentPId(和正确的eventId。

我在 disassociateProperty 方法的第一行放了一个调试点,它告诉我当前 PId 为空。

所以我假设webflow中的requestParameters.currentPId不会从ajax调用中提取currentPId。

这是意料之中的吗?谁能解释并举个例子?

我将不胜感激所提供的任何帮助。

亚当

如果您认为问题来自 ajax 调用,那么在这里编写 ajax 调用会很有帮助,这样我们就可以检查调用是否正确完成。

您可以尝试在执行 ajax 调用时传递在 data 参数中序列化的表单。另外,不要忘记在URL中添加ajaxSource参数。希望这有帮助。

网页示例:

<form id="formId" method="post" action="${flowExecutionUrl}&_eventId=disassociateProperty">
    <input type="text" id="currentPId" />
</form>

j查询示例:

$.ajax({
        type: "POST",
        data: $("#formId").serialize(),
        url: $("#formId").attr("action") + "&ajaxSource=true",
        ...
});

最新更新