1

我正在尝试使用 Spring webflow 进行我的第一个 ajax 调用/响应,并使用 thymeleaf 呈现响应。我使用了他们 pdf Thymeleaf + Spring 3 中的百里香示例。

流配置:

<view-state id="detail" view="bookingDetail"> 
<transitionon="updateData">
<render fragments="hoteldata"/>
</transition>
</view-state>

我的html:

<div id="data" th:fragment="hoteldata">
This is a content to be changed
</div>

<script type="text/javascript" th:src="@{/resources/dojo/dojo.js}"></script>
<script type="text/javascript" th:src="@{/resources/spring/Spring.js}"></script>
<script type="text/javascript" th:src="@{/resources/spring/Spring-Dojo.js}"></script>
...
<form id="triggerform" method="post" action="">
<input type="submit" id="doUpdate" name="_eventId_updateData" value="Update now!" />
</form>
<script type="text/javascript">
Spring.addDecoration(
new Spring.AjaxEventDecoration({formId:'triggerform',elementId:'doUpdate',event:'onclick'}));
</script>

首先我禁用提交:

 <input type="submit" id="doUpdate" name="_eventId_activeOrders" value="Update now!" onclick="return false;"/>

以防止整个页面重新加载。

在日志中,我看到该操作由 SpringWebflow 执行,然后我看到:

Chrome Js 控制台:

Uncaught TypeError: Cannot read property 'method' of null Spring-Dojo.js:16
dojo.declare.submitForm Spring-Dojo.js:16
dojo.declare.submit Spring-Dojo.js:16
dojo.hitch

或 Firefox 控制台:

TypeError: _1a is null
http://localhost:9092/resources/spring/Spring-Dojo.js
Line 16

我不确定如何继续或从哪里开始搜索问题。有人有想法吗?

4

1 回答 1

0

它确实看起来像一个javascript问题,好像DOJO没有找到您的triggerform表单标签(它正在寻找它的method属性但说表单对象为空)......

Could it be that your activeOrders transition is actually modifying that form and removing it, or maybe outputting different HTML for it than the one you show here? I'd suggest trying without the "activeOrders" event part.

And btw, you have a misspelled transitionon attribute in your SWF configuration (should be transition on)

于 2012-11-30T09:05:11.243 回答