Question

I am trying to make my first ajax call / response with Spring webflow, and response rendered with thymeleaf. I have used thymeleaf example from their pdf Thymeleaf + Spring 3.

flow config:

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

my html:

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

and

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

First I disable submit with:

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

to prevent whole page reload.

In logs I see that action is executed by SpringWebflow and then I see :

Chrome Js console:

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

or Firefox console:

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

I am not sure how to proceed or where to start search problems. Anybody have ideas?

Était-ce utile?

La solution

It certainly looks as a javascript problem, as if DOJO isn't finding your triggerform form tag (it's looking for its method attribute but says the form object is null)...

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)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top