Added spring-js support to form fields. Local copy of Spring-Dojo.js is temporary until SWF-605, SWF-606 and SWF-607 are resolved.
Converted tiles to externalized defs.
This commit is contained in:
@@ -17,10 +17,16 @@
|
|||||||
</webflow:flow-executor>
|
</webflow:flow-executor>
|
||||||
|
|
||||||
<!-- The registry of executable flow definitions -->
|
<!-- The registry of executable flow definitions -->
|
||||||
<webflow:flow-registry id="flowRegistry">
|
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
|
||||||
<webflow:flow-location path="/WEB-INF/hotels/booking/booking.xml" />
|
<webflow:flow-location path="/WEB-INF/hotels/booking/booking.xml" />
|
||||||
</webflow:flow-registry>
|
</webflow:flow-registry>
|
||||||
|
|
||||||
|
<webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator"/>
|
||||||
|
|
||||||
|
<bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.view.MvcViewFactoryCreator">
|
||||||
|
<property name="viewResolvers" ref="tilesViewResolver"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- Installs a listener that manages JPA persistence contexts for flows that require them -->
|
<!-- Installs a listener that manages JPA persistence contexts for flows that require them -->
|
||||||
<bean id="jpaFlowExecutionListener" class="org.springframework.webflow.persistence.JpaFlowExecutionListener">
|
<bean id="jpaFlowExecutionListener" class="org.springframework.webflow.persistence.JpaFlowExecutionListener">
|
||||||
<constructor-arg ref="entityManagerFactory" />
|
<constructor-arg ref="entityManagerFactory" />
|
||||||
|
|||||||
@@ -32,10 +32,21 @@
|
|||||||
<property name="order" value="2"/>
|
<property name="order" value="2"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Maps logical view names selected by the url filename controller to .jsp view templates within the /WEB-INF directory -->
|
<!-- Configure Apache Tiles for the view -->
|
||||||
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
|
||||||
<property name="prefix" value="/WEB-INF/" />
|
<property name="definitions">
|
||||||
<property name="suffix" value=".jsp" />
|
<list>
|
||||||
|
<value>/WEB-INF/layouts/layouts.xml</value>
|
||||||
|
<value>/WEB-INF/views.xml</value>
|
||||||
|
<value>/WEB-INF/hotels/views.xml</value>
|
||||||
|
<value>/WEB-INF/hotels/booking/views.xml</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
|
||||||
|
<property name="requestContextAttribute" value="requestContext"/>
|
||||||
|
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Enables annotated POJO @Controllers -->
|
<!-- Enables annotated POJO @Controllers -->
|
||||||
@@ -49,7 +60,4 @@
|
|||||||
<constructor-arg ref="flowExecutor" />
|
<constructor-arg ref="flowExecutor" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Initializes Tiles, the layout engine used in this sample -->
|
|
||||||
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" />
|
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
|
|
||||||
<tiles:insertTemplate template="/WEB-INF/layouts/standard.jsp">
|
|
||||||
<tiles:putAttribute name="content">
|
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h1>Book Hotel</h1>
|
<h1>Book Hotel</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -40,12 +36,19 @@
|
|||||||
<spring:bind path="booking.hotel.price">${status.value}</spring:bind>
|
<spring:bind path="booking.hotel.price">${status.value}</spring:bind>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
<label for="checkinDate">Check In Date:</label>
|
<label for="checkinDate">Check In Date:</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<form:input path="checkinDate"/>
|
<form:input path="checkinDate"/>
|
||||||
|
<script type="text/javascript">
|
||||||
|
dojo.require('dijit.form.DateTextBox');
|
||||||
|
Spring.advisors.push(new Spring.ValidatingFieldAdvisor({
|
||||||
|
targetElId : 'checkinDate',
|
||||||
|
decoratorType : dijit.form.DateTextBox,
|
||||||
|
decoratorAttrs : { value : dojo.date.locale.parse(dojo.byId('checkinDate').value, {selector : 'date', datePattern : 'yyyy-MM-dd'}), required : true }}));
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
@@ -54,6 +57,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<form:input path="checkoutDate"/>
|
<form:input path="checkoutDate"/>
|
||||||
|
<script type="text/javascript">
|
||||||
|
dojo.require('dijit.form.DateTextBox');
|
||||||
|
Spring.advisors.push(new Spring.ValidatingFieldAdvisor({
|
||||||
|
targetElId : 'checkoutDate',
|
||||||
|
decoratorType : dijit.form.DateTextBox,
|
||||||
|
decoratorAttrs : { value : dojo.date.locale.parse(dojo.byId('checkoutDate').value, {selector : 'date', datePattern : 'yyyy-MM-dd'}), required : true }}));
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
@@ -70,11 +80,23 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
<label for="smoking">Smoking Preference:</label>
|
Smoking Preference:
|
||||||
</div>
|
</div>
|
||||||
<div id="radio" class="input">
|
<div id="radio" class="input">
|
||||||
<form:radiobutton id="smoking" path="smoking" label="Smoking" value="true"/>
|
<form:radiobutton id="smoking" path="smoking" label="Smoking" value="true"/>
|
||||||
<form:radiobutton path="smoking" label="Non Smoking" value="false"/>
|
<form:radiobutton id="non-smoking" path="smoking" label="Non Smoking" value="false"/>
|
||||||
|
<script type="text/javascript">
|
||||||
|
dojo.require('dijit.form.CheckBox');
|
||||||
|
Spring.advisors.push(new Spring.ValidatingFieldAdvisor({
|
||||||
|
targetElId : 'smoking',
|
||||||
|
decoratorType : dijit.form.RadioButton,
|
||||||
|
decoratorAttrs : { promptMessage : 'Smoking room' }}));
|
||||||
|
Spring.advisors.push(new Spring.ValidatingFieldAdvisor({
|
||||||
|
targetElId : 'non-smoking',
|
||||||
|
decoratorType : dijit.form.RadioButton,
|
||||||
|
decoratorAttrs : { promptMessage : 'Non-smoking room' }}));
|
||||||
|
</script>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
@@ -82,7 +104,14 @@
|
|||||||
<label for="creditCard">Credit Card #:</label>
|
<label for="creditCard">Credit Card #:</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<form:input id="creditCard" path="creditCard"/>
|
<form:input path="creditCard"/>
|
||||||
|
<script type="text/javascript">
|
||||||
|
dojo.require('dijit.form.ValidationTextBox');
|
||||||
|
Spring.advisors.push(new Spring.ValidatingFieldAdvisor({
|
||||||
|
targetElId : 'creditCard',
|
||||||
|
decoratorType : dijit.form.ValidationTextBox,
|
||||||
|
decoratorAttrs : { required : true, invalidMessage : 'A 16-digit credit card number is required.', regExp : '[0-9]{16}' }}));
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
@@ -90,7 +119,14 @@
|
|||||||
<label for="creditCardName">Credit Card Name:</label>
|
<label for="creditCardName">Credit Card Name:</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<form:input id="creditCardName" path="creditCardName"/>
|
<form:input path="creditCardName" maxlength="4"/>
|
||||||
|
<script type="text/javascript">
|
||||||
|
dojo.require('dijit.form.ValidationTextBox');
|
||||||
|
Spring.advisors.push(new Spring.ValidatingFieldAdvisor({
|
||||||
|
targetElId : 'creditCardName',
|
||||||
|
decoratorType : dijit.form.ValidationTextBox,
|
||||||
|
decoratorAttrs : { required : true }}));
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
@@ -122,12 +158,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttonGroup">
|
<div class="buttonGroup">
|
||||||
<input type="submit" name="_eventId_proceed" value="Proceed"/> 
|
<input type="submit" id="proceed" name="_eventId_proceed" value="Proceed"/> 
|
||||||
<input type="submit" name="_eventId_cancel" value="Cancel"/> 
|
<input type="submit" name="_eventId_cancel" value="Cancel"/> 
|
||||||
|
<script type="text/javascript">
|
||||||
|
Spring.advisors.push(new Spring.ValidateAllAdvisor({event : 'onclick', targetId : 'proceed'}));
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form:form>
|
</form:form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</tiles:putAttribute>
|
|
||||||
</tiles:insertTemplate>
|
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
|
|
||||||
<tiles:insertTemplate template="/WEB-INF/layouts/standard.jsp">
|
|
||||||
<tiles:putAttribute name="content">
|
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h1>Confirm Hotel Booking</h1>
|
<h1>Confirm Hotel Booking</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -63,6 +59,3 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</form:form>
|
</form:form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</tiles:putAttribute>
|
|
||||||
</tiles:insertTemplate>
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE tiles-definitions PUBLIC
|
||||||
|
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
|
||||||
|
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
|
||||||
|
<tiles-definitions>
|
||||||
|
|
||||||
|
<!-- Pages -->
|
||||||
|
<definition name="enterBookingDetails.jsp" extends="standard-layout">
|
||||||
|
<put-attribute name="body" value="/WEB-INF/hotels/booking/enterBookingDetails.jsp" />
|
||||||
|
</definition>
|
||||||
|
|
||||||
|
<definition name="reviewBooking.jsp" extends="standard-layout">
|
||||||
|
<put-attribute name="body" value="/WEB-INF/hotels/booking/reviewBooking.jsp" />
|
||||||
|
</definition>
|
||||||
|
|
||||||
|
</tiles-definitions>
|
||||||
@@ -1,19 +1,22 @@
|
|||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
|
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
|
||||||
|
|
||||||
<tiles:insertTemplate template="/WEB-INF/layouts/standard.jsp">
|
|
||||||
<tiles:putAttribute name="content">
|
|
||||||
|
|
||||||
<form:form modelAttribute="searchCriteria" action="search" method="get">
|
<form:form modelAttribute="searchCriteria" action="search" method="get">
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<span class="errors">
|
<span class="errors">
|
||||||
<form:errors path="*"/>
|
<form:errors path="*"/>
|
||||||
</span>
|
</span>
|
||||||
<h1>Search Hotels</h1>
|
<h1>Search Hotels</h1>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<form:input path="searchString"/>
|
<form:input path="searchString"/>
|
||||||
|
<script type="text/javascript">
|
||||||
|
dojo.require('dijit.form.ValidationTextBox');
|
||||||
|
Spring.advisors.push(new Spring.ValidatingFieldAdvisor({
|
||||||
|
targetElId : 'searchString',
|
||||||
|
decoratorType : dijit.form.ValidationTextBox,
|
||||||
|
decoratorAttrs : { promptMessage : 'Search hotels by name, address, city, or zip.' }}));
|
||||||
|
</script>
|
||||||
<label for="pageSize">Maximum results:</label>
|
<label for="pageSize">Maximum results:</label>
|
||||||
<form:select path="pageSize">
|
<form:select path="pageSize">
|
||||||
<form:option label="5" value="5"/>
|
<form:option label="5" value="5"/>
|
||||||
@@ -64,6 +67,3 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</security:authorize>
|
</security:authorize>
|
||||||
|
|
||||||
</tiles:putAttribute>
|
|
||||||
</tiles:insertTemplate>
|
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
|
|
||||||
<tiles:insertTemplate template="/WEB-INF/layouts/standard.jsp">
|
|
||||||
<tiles:putAttribute name="content">
|
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h1>Hotel Results</h1>
|
<h1>Hotel Results</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -42,6 +38,3 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</c:if>
|
</c:if>
|
||||||
|
|
||||||
</tiles:putAttribute>
|
|
||||||
</tiles:insertTemplate>
|
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
|
|
||||||
<tiles:insertTemplate template="/WEB-INF/layouts/standard.jsp">
|
|
||||||
<tiles:putAttribute name="content">
|
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h1>View Hotel</h1>
|
<h1>View Hotel</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -50,6 +46,3 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</form:form>
|
</form:form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</tiles:putAttribute>
|
|
||||||
</tiles:insertTemplate>
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE tiles-definitions PUBLIC
|
||||||
|
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
|
||||||
|
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
|
||||||
|
<tiles-definitions>
|
||||||
|
|
||||||
|
<!-- Pages -->
|
||||||
|
<definition name="hotels/index" extends="standard-layout">
|
||||||
|
<put-attribute name="body" value="/WEB-INF/hotels/index.jsp" />
|
||||||
|
</definition>
|
||||||
|
|
||||||
|
<definition name="hotels/search" extends="standard-layout">
|
||||||
|
<put-attribute name="body" value="/WEB-INF/hotels/search.jsp" />
|
||||||
|
</definition>
|
||||||
|
|
||||||
|
<definition name="hotels/show" extends="standard-layout">
|
||||||
|
<put-attribute name="body" value="/WEB-INF/hotels/show.jsp" />
|
||||||
|
</definition>
|
||||||
|
|
||||||
|
</tiles-definitions>
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
|
||||||
|
|
||||||
<tiles:insertTemplate template="/WEB-INF/layouts/standard.jsp">
|
|
||||||
<tiles:putAttribute name="content">
|
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h1>Welcome to Spring Travel</h1>
|
<h1>Welcome to Spring Travel</h1>
|
||||||
@@ -28,6 +24,3 @@
|
|||||||
<a href="main">Start your Spring Travel experience</a>
|
<a href="main">Start your Spring Travel experience</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</tiles:putAttribute>
|
|
||||||
</tiles:insertTemplate>
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE tiles-definitions PUBLIC
|
||||||
|
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
|
||||||
|
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
|
||||||
|
<tiles-definitions>
|
||||||
|
|
||||||
|
<!-- Layout -->
|
||||||
|
<definition name="standard-layout" template="/WEB-INF/layouts/standard.jsp" />
|
||||||
|
|
||||||
|
</tiles-definitions>
|
||||||
@@ -15,6 +15,10 @@
|
|||||||
@import url("<c:url value="/resources/css-framework/css/layout.css" />");
|
@import url("<c:url value="/resources/css-framework/css/layout.css" />");
|
||||||
@import url("<c:url value="/resources/styles/booking.css" />");
|
@import url("<c:url value="/resources/styles/booking.css" />");
|
||||||
</style>
|
</style>
|
||||||
|
<script type="text/javascript" src="<c:url value="/resources/spring/Spring.js" />"></script>
|
||||||
|
<script type="text/javascript" src="<c:url value="/resources/dojo/dojo.js" />"></script>
|
||||||
|
<script type="text/javascript" src="<c:url value="/resources/spring/Spring-Dojo.js" />"></script>
|
||||||
|
<link type="text/css" rel="stylesheet" href="<c:url value="/resources/dijit/themes/tundra/tundra.css" />" />
|
||||||
</head>
|
</head>
|
||||||
<body class="tundra spring">
|
<body class="tundra spring">
|
||||||
<div id="page">
|
<div id="page">
|
||||||
@@ -49,7 +53,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<tiles:insertAttribute name="content" />
|
<tiles:insertAttribute name="body" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="footer" class="clearfix spring">
|
<div id="footer" class="clearfix spring">
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
|
|
||||||
<%@ page import="org.springframework.security.ui.AbstractProcessingFilter" %>
|
<%@ page import="org.springframework.security.ui.AbstractProcessingFilter" %>
|
||||||
<%@ page import="org.springframework.security.ui.webapp.AuthenticationProcessingFilter" %>
|
<%@ page import="org.springframework.security.ui.webapp.AuthenticationProcessingFilter" %>
|
||||||
<%@ page import="org.springframework.security.AuthenticationException" %>
|
<%@ page import="org.springframework.security.AuthenticationException" %>
|
||||||
|
|
||||||
<tiles:insertTemplate template="/WEB-INF/layouts/standard.jsp">
|
|
||||||
<tiles:putAttribute name="content">
|
|
||||||
|
|
||||||
<h1>Login Required</h1>
|
<h1>Login Required</h1>
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
@@ -21,9 +17,9 @@
|
|||||||
<p>Valid username/passwords are:</p>
|
<p>Valid username/passwords are:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>keith/melbourne</li>
|
<li>keith/melbourne</li>
|
||||||
<li>erwin/leuven</li>
|
<li>erwin/leuven</li>
|
||||||
<li>jeremy/atlanta</li>
|
<li>jeremy/atlanta</li>
|
||||||
<li>scott/rochester</li>
|
<li>scott/rochester</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -31,30 +27,50 @@
|
|||||||
<form name="f" action="<c:url value="/spring/login-process" />" method="post">
|
<form name="f" action="<c:url value="/spring/login-process" />" method="post">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label">User:</div>
|
<div class="label"><label for="j_username">User:</label></div>
|
||||||
<div class="output">
|
<div class="output">
|
||||||
<input type="text" name="j_username" <c:if test="${not empty param.login_error}">value="<%= session.getAttribute(AuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY) %>"</c:if> />
|
<input type="text" name="j_username" id="j_username" <c:if test="${not empty param.login_error}">value="<%= session.getAttribute(AuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY) %>"</c:if> />
|
||||||
|
<script type="text/javascript">
|
||||||
|
dojo.require('dijit.form.ValidationTextBox');
|
||||||
|
Spring.advisors.push(new Spring.ValidatingFieldAdvisor({
|
||||||
|
targetElId : 'j_username',
|
||||||
|
decoratorType : dijit.form.ValidationTextBox,
|
||||||
|
decoratorAttrs : { promptMessage : 'Your username', required : true }}));
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label">Password:</div>
|
<div class="label"><label for="j_password">Password:</label></div>
|
||||||
<div class="output">
|
<div class="output">
|
||||||
<input type="password" name="j_password" />
|
<input type="password" name="j_password" id="j_password" />
|
||||||
|
<script type="text/javascript">
|
||||||
|
dojo.require('dijit.form.ValidationTextBox');
|
||||||
|
Spring.advisors.push(new Spring.ValidatingFieldAdvisor({
|
||||||
|
targetElId : 'j_password',
|
||||||
|
decoratorType : dijit.form.ValidationTextBox,
|
||||||
|
decoratorAttrs : { promptMessage : 'Your password', required : true, type : 'password' }}));
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label">Don't ask for my password for two weeks:</div>
|
<div class="label"><label for="remember_me">Don't ask for my password for two weeks:</label></div>
|
||||||
<div class="output">
|
<div class="output">
|
||||||
<input type="checkbox" name="_spring_security_remember_me" />
|
<input type="checkbox" name="_spring_security_remember_me" id="remember_me" />
|
||||||
|
<script type="text/javascript">
|
||||||
|
dojo.require('dijit.form.CheckBox');
|
||||||
|
Spring.advisors.push(new Spring.ValidatingFieldAdvisor({
|
||||||
|
targetElId : 'remember_me',
|
||||||
|
decoratorType : dijit.form.CheckBox,
|
||||||
|
decoratorAttrs : { promptMessage : 'Remember me for 2 weeks' }}));
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="buttonGroup">
|
<div class="buttonGroup">
|
||||||
<input name="submit" type="submit" value="Login" />
|
<input name="submit" id="submit" type="submit" value="Login" />
|
||||||
|
<script type="text/javascript">
|
||||||
|
Spring.advisors.push(new Spring.ValidateAllAdvisor({event : 'onclick', targetId : 'submit'}));
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</tiles:putAttribute>
|
|
||||||
</tiles:insertTemplate>
|
|
||||||
@@ -1,16 +1,7 @@
|
|||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
|
||||||
|
|
||||||
<tiles:insertTemplate template="/WEB-INF/layouts/standard.jsp">
|
|
||||||
<tiles:putAttribute name="content">
|
|
||||||
|
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h1>Logout</h1>
|
<h1>Logout</h1>
|
||||||
<p>You have successfully logged out.</p>
|
<p>You have successfully logged out.</p>
|
||||||
<p><a href="<c:url value="/" />">Continue</a></p>
|
<p><a href="<c:url value="/" />">Continue</a></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</tiles:putAttribute>
|
|
||||||
</tiles:insertTemplate>
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE tiles-definitions PUBLIC
|
||||||
|
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
|
||||||
|
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
|
||||||
|
<tiles-definitions>
|
||||||
|
|
||||||
|
<!-- Pages -->
|
||||||
|
<definition name="intro" extends="standard-layout">
|
||||||
|
<put-attribute name="body" value="/WEB-INF/intro.jsp" />
|
||||||
|
</definition>
|
||||||
|
|
||||||
|
<definition name="login" extends="standard-layout">
|
||||||
|
<put-attribute name="body" value="/WEB-INF/login.jsp" />
|
||||||
|
</definition>
|
||||||
|
|
||||||
|
<definition name="logout-success" extends="standard-layout">
|
||||||
|
<put-attribute name="body" value="/WEB-INF/logout-success.jsp" />
|
||||||
|
</definition>
|
||||||
|
|
||||||
|
</tiles-definitions>
|
||||||
@@ -0,0 +1,343 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2004-2008 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
Spring.DojoValidatingFieldAdvisor = function(config){
|
||||||
|
|
||||||
|
dojo.mixin(this, config);
|
||||||
|
};
|
||||||
|
|
||||||
|
Spring.DojoValidatingFieldAdvisor.prototype = {
|
||||||
|
|
||||||
|
targetElId : "",
|
||||||
|
decoratorType : null,
|
||||||
|
decorator : null,
|
||||||
|
decoratorAttrs : null,
|
||||||
|
copyFields : new Array('name', 'value', 'type', 'checked', 'selected', 'readOnly', 'disabled', 'alt', 'maxLength'),
|
||||||
|
|
||||||
|
apply : function(){
|
||||||
|
if (dijit.byId(this.targetElId)) {
|
||||||
|
dijit.byId(this.targetElId).destroyRecursive(false);
|
||||||
|
}
|
||||||
|
var targetEl = dojo.byId(this.targetElId);
|
||||||
|
for (var copyField in this.copyFields) {
|
||||||
|
copyField = this.copyFields[copyField];
|
||||||
|
if (!this.decoratorAttrs[copyField] && targetEl[copyField] && (typeof targetEl[copyField] != 'number' || (typeof targetEl[copyField] == 'number' && targetEl[copyField] >= 0))) {
|
||||||
|
this.decoratorAttrs[copyField] = targetEl[copyField];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.decorator = new this.decoratorType(this.decoratorAttrs, targetEl);
|
||||||
|
this.decorator.startup();
|
||||||
|
//return this to support method chaining
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
validate : function(){
|
||||||
|
if (!this.decorator.isValid) {
|
||||||
|
// some decorators cannot be validated
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
var isValid = this.decorator.isValid(false);
|
||||||
|
if (!isValid) {
|
||||||
|
this.decorator.state = "Error";
|
||||||
|
this.decorator._setStateClass();
|
||||||
|
}
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Spring.ValidatingFieldAdvisor = Spring.DojoValidatingFieldAdvisor;
|
||||||
|
|
||||||
|
Spring.DojoRemoteEventAdvisor = function(config){
|
||||||
|
dojo.mixin(this, config);
|
||||||
|
};
|
||||||
|
|
||||||
|
Spring.DojoRemoteEventAdvisor.prototype = {
|
||||||
|
|
||||||
|
event : "",
|
||||||
|
targetId : "",
|
||||||
|
sourceId : "",
|
||||||
|
formId : "",
|
||||||
|
processIds : "",
|
||||||
|
renderIds : "",
|
||||||
|
params : [],
|
||||||
|
connection : null,
|
||||||
|
|
||||||
|
apply : function() {
|
||||||
|
this.connection = dojo.connect(dojo.byId(this.targetId), this.event, this, "submit");
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
cleanup : function(){
|
||||||
|
dojo.disconnect(this.connection);
|
||||||
|
},
|
||||||
|
|
||||||
|
submit : function(){
|
||||||
|
Spring.RemotingHandler.submitForm(this.sourceId, this.formId, this.processIds, this.renderIds, this.params);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Spring.RemoteEventAdvisor = Spring.DojoRemoteEventAdvisor;
|
||||||
|
|
||||||
|
Spring.DojoValidateAllAdvisor = function(config){
|
||||||
|
dojo.mixin(this, config);
|
||||||
|
};
|
||||||
|
|
||||||
|
Spring.DojoValidateAllAdvisor.prototype = {
|
||||||
|
|
||||||
|
event : "",
|
||||||
|
targetId : "",
|
||||||
|
originalHandler : null,
|
||||||
|
connection : null,
|
||||||
|
|
||||||
|
apply : function() {
|
||||||
|
var targetEl = dojo.byId(this.targetId);
|
||||||
|
this.originalHandler = targetEl[this.event];
|
||||||
|
var context = this;
|
||||||
|
targetEl[this.event] = function(event){
|
||||||
|
context.handleEvent(event, context);
|
||||||
|
};
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
cleanup : function(){
|
||||||
|
dojo.disconnect(this.connection);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleEvent : function(event, context){
|
||||||
|
if (!Spring.validateAll()) {
|
||||||
|
dojo.stopEvent(event);
|
||||||
|
} else {
|
||||||
|
var result = context.originalHandler(event);
|
||||||
|
if (result == false) {
|
||||||
|
dojo.stopEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Spring.ValidateAllAdvisor = Spring.DojoValidateAllAdvisor;
|
||||||
|
|
||||||
|
Spring.DojoRemotingHandler = function(){};
|
||||||
|
|
||||||
|
Spring.DojoRemotingHandler.prototype = {
|
||||||
|
|
||||||
|
submitForm : function(/*String */ sourceId, /*String*/formId, /*String*/ processIds, /*String*/renderIds, /*Array*/ params) {
|
||||||
|
var content = new Object();
|
||||||
|
var sourceComponent = dojo.byId(sourceId);
|
||||||
|
content['processIds'] = processIds;
|
||||||
|
content['renderIds'] = renderIds;
|
||||||
|
|
||||||
|
if (sourceComponent != null){
|
||||||
|
if(sourceComponent.value) {
|
||||||
|
content[sourceId] = sourceComponent.value;
|
||||||
|
} else {
|
||||||
|
content[sourceId] = sourceId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dojo.forEach(params, function(param){
|
||||||
|
content[param.name] = param.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
content['ajaxSource'] = sourceId;
|
||||||
|
|
||||||
|
dojo.xhrPost({
|
||||||
|
|
||||||
|
content: content,
|
||||||
|
|
||||||
|
form: formId,
|
||||||
|
|
||||||
|
handleAs: "text",
|
||||||
|
|
||||||
|
headers: {"Accept" : "text/html;type=ajax"},
|
||||||
|
|
||||||
|
// The LOAD function will be called on a successful response.
|
||||||
|
load: this.handleResponse,
|
||||||
|
|
||||||
|
// The ERROR function will be called in an error case.
|
||||||
|
error: this.handleError
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
getLinkedResource: function(/*String */ linkId, /*boolean*/ modal) {
|
||||||
|
this.getResource(dojo.byId(linkId).href, modal);
|
||||||
|
},
|
||||||
|
|
||||||
|
getResource: function(/*String */ resourceUri, /*boolean*/ modal) {
|
||||||
|
|
||||||
|
dojo.xhrGet({
|
||||||
|
|
||||||
|
url: resourceUri,
|
||||||
|
|
||||||
|
handleAs: "text",
|
||||||
|
|
||||||
|
load: this.handleResponse,
|
||||||
|
|
||||||
|
error: this.handleError,
|
||||||
|
|
||||||
|
modal: modal
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
handleResponse: function(response, ioArgs) {
|
||||||
|
|
||||||
|
//First check if this response should redirect
|
||||||
|
var redirectURL = ioArgs.xhr.getResponseHeader('Flow-Redirect-URL');
|
||||||
|
var modalViewHeader = ioArgs.xhr.getResponseHeader('Flow-Modal-View');
|
||||||
|
var modalView = ((dojo.isString(modalViewHeader) && modalViewHeader.length > 0) || ioArgs.args.modal);
|
||||||
|
|
||||||
|
if (dojo.isString(redirectURL) && redirectURL.length > 0) {
|
||||||
|
if (modalView) {
|
||||||
|
//render a popup with the new URL
|
||||||
|
Spring.RemotingHandler.renderURLToModalDialog(redirectURL, ioArgs);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window.location = window.location.protocol + "//" + window.location.host + redirectURL;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Extract and store all <script> elements from the response
|
||||||
|
var scriptPattern = '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)';
|
||||||
|
var extractedScriptNodes = [];
|
||||||
|
var matchAll = new RegExp(scriptPattern, 'img');
|
||||||
|
var matchOne = new RegExp(scriptPattern, 'im');
|
||||||
|
|
||||||
|
var scriptNodes = response.match(matchAll);
|
||||||
|
if (scriptNodes != null)
|
||||||
|
{
|
||||||
|
for (var i=0; i<scriptNodes.length; i++)
|
||||||
|
{
|
||||||
|
var script = (scriptNodes[i].match(matchOne) || ['',''])[1];
|
||||||
|
script = script.replace(/<!--/mg,'').replace(/\/\/-->/mg,'');
|
||||||
|
extractedScriptNodes.push(script);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response = response.replace(matchAll, '');
|
||||||
|
|
||||||
|
//Extract the new DOM nodes from the response
|
||||||
|
var tempDiv = dojo.doc.createElement("div");
|
||||||
|
tempDiv.id="ajaxResponse";
|
||||||
|
tempDiv.style.visibility= "hidden";
|
||||||
|
document.body.appendChild(tempDiv);
|
||||||
|
var tempContainer = new dojo.NodeList(tempDiv);
|
||||||
|
var newNodes = tempContainer.addContent(response, "first").query("#ajaxResponse > *").orphan();
|
||||||
|
tempContainer.orphan();
|
||||||
|
|
||||||
|
//For a modal view, just dump the new nodes into a modal dialog
|
||||||
|
if (modalView) {
|
||||||
|
Spring.RemotingHandler.renderNodeListToModalDialog(newNodes);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
//Insert the new DOM nodes and update the Form's action URL
|
||||||
|
newNodes.forEach(function(item){
|
||||||
|
if (item.id != null && item.id != "") {
|
||||||
|
var target = dojo.byId(item.id);
|
||||||
|
target.parentNode.replaceChild(item, target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//Evaluate any script code
|
||||||
|
dojo.forEach(extractedScriptNodes, function(script){
|
||||||
|
dojo.eval(script);
|
||||||
|
});
|
||||||
|
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
|
||||||
|
handleError: function(response, ioArgs) {
|
||||||
|
console.error("HTTP status code: ", ioArgs.xhr.status);
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
|
||||||
|
renderURLToModalDialog: function(url, ioArgs) {
|
||||||
|
url = url + "&"+dojo.objectToQuery(ioArgs.args.content);
|
||||||
|
|
||||||
|
Spring.RemotingHandler.getResource(url, true);
|
||||||
|
},
|
||||||
|
|
||||||
|
renderNodeListToModalDialog: function(nodes) {
|
||||||
|
dojo.require("dijit.Dialog");
|
||||||
|
|
||||||
|
var dialog = new dijit.Dialog({});
|
||||||
|
dialog.setContent(nodes);
|
||||||
|
dojo.connect(dialog, "hide", dialog, function(){
|
||||||
|
this.destroyRecursive(false);
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Spring.RemotingHandler = new Spring.DojoRemotingHandler();
|
||||||
|
|
||||||
|
Spring.DojoCommandLinkAdvisor = function(config){
|
||||||
|
dojo.mixin(this, config);
|
||||||
|
};
|
||||||
|
|
||||||
|
Spring.DojoCommandLinkAdvisor.prototype = {
|
||||||
|
|
||||||
|
targetElId : "",
|
||||||
|
|
||||||
|
linkHtml : "",
|
||||||
|
|
||||||
|
apply : function(){
|
||||||
|
var advisedNode = dojo.byId(this.targetElId);
|
||||||
|
if (!dojo.hasClass(advisedNode, "progressiveLink")) {
|
||||||
|
//Node must be replaced
|
||||||
|
var nodeToReplace = new dojo.NodeList(advisedNode);
|
||||||
|
nodeToReplace.addContent(this.linkHtml, "after").orphan("*");
|
||||||
|
//Get the new node
|
||||||
|
advisedNode = dojo.byId(this.targetElId);
|
||||||
|
}
|
||||||
|
advisedNode.submitFormFromLink = this.submitFormFromLink;
|
||||||
|
//return this to support method chaining
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
submitFormFromLink : function(/*String*/ formId, /*String*/ sourceId, /*Array of name,value params*/ params){
|
||||||
|
var addedNodes = [];
|
||||||
|
var formNode = dojo.byId(formId);
|
||||||
|
var linkNode = document.createElement("input");
|
||||||
|
linkNode.name = sourceId;
|
||||||
|
linkNode.value = "submitted";
|
||||||
|
addedNodes.push(linkNode);
|
||||||
|
|
||||||
|
dojo.forEach(params, function(param){
|
||||||
|
var paramNode = document.createElement("input");
|
||||||
|
paramNode.name=param.name;
|
||||||
|
paramNode.value=param.value;
|
||||||
|
addedNodes.push(paramNode);
|
||||||
|
});
|
||||||
|
|
||||||
|
dojo.forEach(addedNodes, function(nodeToAdd){
|
||||||
|
dojo.addClass(nodeToAdd, "SpringLinkInput");
|
||||||
|
dojo.place(nodeToAdd, formNode, "last");
|
||||||
|
});
|
||||||
|
|
||||||
|
if ((formNode.onsubmit ? !formNode.onsubmit() : false) || !formNode.submit()) {
|
||||||
|
dojo.forEach(addedNodes, function(hiddenNode){
|
||||||
|
formNode.removeChild(hiddenNode);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Spring.CommandLinkAdvisor = Spring.DojoCommandLinkAdvisor;
|
||||||
|
|
||||||
|
dojo.addOnLoad(Spring.applyAdvisors);
|
||||||
Reference in New Issue
Block a user