All '/resources' URLs are resolved by Spring JavaScript's the ResourceServlet
configured in the web.xml.
<link type="text/css" rel="stylesheet" href="<c:url value="/resources/dijit/themes/tundra/tundra.css" />" /> <script type="text/javascript" src="<c:url value="/resources/dojo/dojo.js" />"></script> <script type="text/javascript" src="<c:url value="/resources/spring/Spring.js" />"></script> <script type="text/javascript" src="<c:url value="/resources/spring/Spring-Dojo.js" />"></script>
The create link goes to '/person.html' which is mapped to the person flow. The search link still goes through the PersonController
.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <div id="side-bar"> <a href="<c:url value="/"/>">Home</a> <p><fmt:message key="person.form.title"/></p> <a href="<c:url value="/person.html"/>"><fmt:message key="button.create"/></a> <a href="<c:url value="/person/search.html"/>"><fmt:message key="button.search"/></a> </div>
The edit link goes to the person flow (ex: '/person.html?id=1'). The flow will look up the person record based on the id request parameter.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> <h1><fmt:message key="person.search.title"/></h1> <table class="search"> <tr> <th><fmt:message key="person.form.firstName"/></th> <th><fmt:message key="person.form.lastName"/></th> </tr> <c:forEach var="person" items="${persons}"> <tr> <c:url var="editUrl" value="/person.html"> <c:param name="id" value="${person.id}" /> </c:url> <c:url var="deleteUrl" value="/person/delete.html"> <c:param name="id" value="${person.id}" /> </c:url> <td>${person.firstName}</td> <td>${person.lastName}</td> <td> <a href='<c:out value="${editUrl}"/>'><fmt:message key="button.edit"/></a> <sec:authorize ifAllGranted="ROLE_ADMIN"> <a href='<c:out value="${deleteUrl}"/>'><fmt:message key="button.delete"/></a> </sec:authorize> </td> </tr> </c:forEach> </table>
The form:form element just needs to have it's modelAttribute set to correspond to where the flow put
the Person
instance. The save and cancel buttons specify which event id they are associated with for this step in the flow.
This value should match the flow's transition element's on attribute. Just for an example,
Spring JavaScript is being used to submit the save button. It isn't really necessary for the example, but it could specify to have just
a div on the page update. Like if there was a messages div, this JavaScript, Spring.remoting.submitForm('save', 'person', {fragments:'messages'}); return false;
could be used to display success or failure messages without updating the entire page.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> <h1><fmt:message key="person.form.title"/></h1> <form:form modelAttribute="person"> <form:hidden path="id" /> <fieldset> <div class="form-row"> <label for="firstName"><fmt:message key="person.form.firstName"/>:</label> <span class="input"><form:input path="firstName" /></span> </div> <div class="form-row"> <label for="lastName"><fmt:message key="person.form.lastName"/>:</label> <span class="input"><form:input path="lastName" /></span> </div> <div class="form-buttons"> <div class="button"> <input type="submit" id="save" name="_eventId_save" value="<fmt:message key="button.save"/>" onclick="Spring.remoting.submitForm('save', 'person')"/>  <input type="submit" name="_eventId_cancel" value="Cancel"/>  </div> </div> </fieldset> </form:form>