After scouring the Internet and various forums, I'm very close to getting Ajax functionality working. The Ajax submit does kick off the "refreshSourceDocumentSection" transition, but the fragment is not re-rendered (the page doesn't even reload). Does anyone see anything wrong with the code? Am I missing something for this to work?
In my Spring configuration:
The pertinent tiles:Code:<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass"> <value> org.springframework.web.servlet.view.tiles2.TilesView </value> </property> </bean> <bean id="ajaxViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver"> <property name="viewClass" value="org.springframework.webflow.mvc.view.FlowAjaxTilesView"/> </bean>
The flow definition:Code:<definition name="editIssuePage" template="/WEB-INF/jsp/templates/soc_template.jsp"> <put-attribute name="title" value="Issue"/> <put-attribute name="body" value="editIssueBody"/> </definition> <definition name="editIssueBody" template="/WEB-INF/flow/issue/editIssue.jsp"> <put-attribute name="sourceDocumentSection" value="/WEB-INF/flow/issue/sourceDocumentSection.jsp"/> </definition>
And finally, the pertinent section of the JSP:Code:<?xml version="1.0" encoding="UTF-8"?> <flow xmlns="http://www.springframework.org/schema/webflow" 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"> <secured attributes="ROLE_ADMIN,ROLE_ANALYST" /> <persistence-context/> <input name="id" required="false"/> <on-start> <evaluate expression="issueService.getIssue(id)" result="flowScope.issue"/> </on-start> <view-state id="editIssue" view="editIssuePage" model="issue"> <on-entry> <set name="viewScope.userList" value="userService.getUserDropdownList()"/> <set name="viewScope.agencyList" value="loaService.getLoaDropdownList()"/> <set name="viewScope.priorityList" value="priorityService.getPriorityDropdownList()"/> <set name="viewScope.sourceDocumentList" value="sourceDocumentService.getSourceDocumentWithSectionsDropdownList()"/> <set name="viewScope.sourceDocumentSectionList" value="sourceDocumentSectionService.getSectionDropdownListBySourceDocumentId(issue.sourceDocumentSection.sourceDocument.id)"/> </on-entry> <transition on="refreshSourceDocumentSection"> <set name="viewScope.sourceDocumentSectionList" value="sourceDocumentSectionService.getSectionDropdownListBySourceDocumentId(requestParameters.sourceDocument)"/> <render fragments="sourceDocumentSection"/> </transition> <transition on="cancel" to="cancelEdit"/> <transition on="submit" to="saveIssue"/> </view-state> <end-state id="saveIssue" commit="true" view="externalRedirect:contextRelative:dashboard/issueTable.htm"/> <end-state id="cancelEdit" commit="false" view="externalRedirect:contextRelative:dashboard/issueTable.htm"/> </flow>
Code:<tr> <th>Source Document:</th> <td class="required"> <select id="sourceDocument" name="sourceDocument"> <c:forEach var="sd" items="${sourceDocumentList}"> <option value="${sd.id}" <c:if test="${sd.id == issue.sourceDocumentSection.sourceDocument.id}">selected="selected"</c:if> >${sd.name}</option> </c:forEach> </select> <script type="text/javascript"> Spring.addDecoration(new Spring.AjaxEventDecoration({ formId: "issueForm", elementId: "sourceDocument", event: "onchange", params: { _eventId: "refreshSourceDocumentSection" } })); </script> </td> </tr> <tr> <th>Source Document Section:</th> <td class="required"> <div id="sourceDocumentSection"> <tiles:insertAttribute name="sourceDocumentSection"/> </div> </td> </tr>


Reply With Quote
