-Moving AjaxHandler to spring-js

-Polishing Spring.js API
-Refactoring spring-faces components to match Spring.js API changes.
This commit is contained in:
Jeremy Grelle
2008-04-22 22:28:11 +00:00
parent 0f3d983587
commit 7d3e1d611b
23 changed files with 308 additions and 215 deletions

View File

@@ -0,0 +1,77 @@
package org.springframework.js.ajax.view;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.tiles.Attribute;
import org.apache.tiles.Definition;
import org.apache.tiles.Attribute.AttributeType;
import org.apache.tiles.access.TilesAccess;
import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.impl.BasicTilesContainer;
import org.springframework.js.mvc.servlet.AjaxHandler;
import org.springframework.js.mvc.servlet.SpringJavascriptAjaxHandler;
import org.springframework.web.servlet.support.JstlUtils;
import org.springframework.web.servlet.support.RequestContext;
import org.springframework.web.servlet.view.tiles2.TilesView;
public class TilesAjaxView extends TilesView {
public static final String FRAGMENTS_PARAM = "fragments";
private AjaxHandler ajaxHandler = new SpringJavascriptAjaxHandler();
protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
throws Exception {
ServletContext servletContext = getServletContext();
if (ajaxHandler.isAjaxRequest(servletContext, request, response)) {
BasicTilesContainer container = (BasicTilesContainer) TilesAccess.getContainer(servletContext);
if (container == null) {
throw new ServletException("Tiles container is not initialized. "
+ "Have you added a TilesConfigurer to your web application context?");
}
exposeModelAsRequestAttributes(model, request);
JstlUtils.exposeLocalizationContext(new RequestContext(request, servletContext));
TilesRequestContext tilesRequestContext = container.getContextFactory().createRequestContext(
container.getApplicationContext(), new Object[] { request, response });
Definition compositeDefinition = container.getDefinitionsFactory().getDefinition(getUrl(),
tilesRequestContext);
Map flattenedAttributeMap = new HashMap();
flattenAttributeMap(container, tilesRequestContext, flattenedAttributeMap, compositeDefinition);
String attrName = request.getParameter(FRAGMENTS_PARAM);
Attribute attributeToRender = (Attribute) flattenedAttributeMap.get(attrName);
container.render(attributeToRender, response.getWriter(), new Object[] { request, response });
} else {
super.renderMergedOutputModel(model, request, response);
}
}
private void flattenAttributeMap(BasicTilesContainer container, TilesRequestContext requestContext, Map resultMap,
Definition compositeDefinition) throws Exception {
Iterator i = compositeDefinition.getAttributes().keySet().iterator();
while (i.hasNext()) {
Object key = i.next();
Attribute attr = (Attribute) compositeDefinition.getAttributes().get(key);
if (attr.getType() == AttributeType.DEFINITION) {
Definition nestedDefinition = container.getDefinitionsFactory().getDefinition(
attr.getValue().toString(), requestContext);
flattenAttributeMap(container, requestContext, resultMap, nestedDefinition);
} else {
resultMap.put(key, attr);
}
}
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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.
*/
package org.springframework.js.mvc.servlet;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Strategy interface that encapsulates knowledge about a client-side ajax system and how to communicate with that
* system.
* @author Keith Donald
*/
public interface AjaxHandler {
/**
* Is the current request an Ajax request?
* @param request the current request
*/
public boolean isAjaxRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response);
/**
* Send a redirect request to the Ajax client. This should cause the client-side agent to send a new request to the
* specified target url.
* @param response the response object
* @param targetUrl the target url to redirect to
* @param popup wheter the redirect should be sent from a new popup dialog window
*/
public void sendAjaxRedirect(ServletContext context, HttpServletRequest request, HttpServletResponse response,
String targetUrl, boolean popup) throws IOException;
}

View File

@@ -0,0 +1,72 @@
/*
* 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.
*/
package org.springframework.js.mvc.servlet;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.util.StringUtils;
/**
* Ajax handler for Spring Javascript (Spring.js).
*
* @author Jeremy Grelle
* @author Keith Donald
*/
public class SpringJavascriptAjaxHandler implements AjaxHandler {
/**
* The response header to be set on an Ajax redirect
*/
public static final String REDIRECT_URL_HEADER = "Spring-Redirect-URL";
/**
* The response header to be set on an redirect that should be issued from a popup window.
*/
public static final String POPUP_VIEW_HEADER = "Spring-Modal-View";
/**
* The accept header value that signifies an Ajax request.
*/
public static final String AJAX_ACCEPT_CONTENT_TYPE = "text/html;type=ajax";
/**
* Alternate request parameter to indicate an Ajax request for cases when control of the header is not available.
*/
public static final String AJAX_SOURCE_PARAM = "ajaxSource";
public boolean isAjaxRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response) {
String acceptHeader = request.getHeader("Accept");
String ajaxParam = request.getParameter(AJAX_SOURCE_PARAM);
if (AJAX_ACCEPT_CONTENT_TYPE.equals(acceptHeader) || StringUtils.hasText(ajaxParam)) {
return true;
} else {
return false;
}
}
public void sendAjaxRedirect(ServletContext context, HttpServletRequest request, HttpServletResponse response,
String targetUrl, boolean popup) throws IOException {
if (popup) {
response.setHeader(POPUP_VIEW_HEADER, "true");
}
response.setHeader(REDIRECT_URL_HEADER, response.encodeRedirectURL(targetUrl));
}
}

File diff suppressed because one or more lines are too long

View File

@@ -13,88 +13,62 @@
* 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 : "",
decorator : null,
decoratorAttrs : "",
apply : function(){
if (dijit.byId(this.targetElId)) {
dijit.byId(this.targetElId).destroyRecursive(false);
dojo.declare("Spring.ElementDecoration", Spring.AbstractElementDecoration, {
constructor : function(config) {
this.copyFields = new Array('name', 'value', 'type', 'checked', 'selected', 'readOnly', 'disabled', 'alt', 'maxLength');
dojo.mixin(this, config);
if(this.widgetModule == "") {
this.widgetModule = this.widgetType;
}
this.decorator = eval("new "+ this.decoratorType + "(" + this.decoratorAttrs +", dojo.byId('"+this.targetElId+"'));" );
this.decorator.startup();
},
apply : function(){
if (dijit.byId(this.elementId)) {
dijit.byId(this.elementId).destroyRecursive(false);
}
var element = dojo.byId(this.elementId);
for (var copyField in this.copyFields) {
copyField = this.copyFields[copyField];
if (!this.widgetAttrs[copyField] && element[copyField] && (typeof element[copyField] != 'number' ||
(typeof element[copyField] == 'number' && element[copyField] >= 0))) {
this.widgetAttrs[copyField] = element[copyField];
}
}
dojo.require(this.widgetModule);
var widgetConstructor = dojo.eval(this.widgetType);
this.widget = new widgetConstructor(this.widgetAttrs, element);
this.widget.startup();
//return this to support method chaining
return this;
},
validate : function(){
var isValid = this.decorator.isValid(false);
if (!this.widget.isValid) {
// some widgets cannot be validated
return true;
}
var isValid = this.widget.isValid(false);
if (!isValid) {
this.decorator.state = "Error";
this.decorator._setStateClass();
this.widget.state = "Error";
this.widget._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;
dojo.declare("Spring.ValidateAllDecoration", Spring.AbstractValidateAllDecoration, {
constructor : function(config) {
this.originalHandler = null;
this.connection = null;
dojo.mixin(this, config);
},
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 element = dojo.byId(this.elementId);
this.originalHandler = element[this.event];
var context = this;
targetEl[this.event] = function(event){
element[this.event] = function(event){
context.handleEvent(event, context);
};
return this;
@@ -107,40 +81,65 @@ Spring.DojoValidateAllAdvisor.prototype = {
handleEvent : function(event, context){
if (!Spring.validateAll()) {
dojo.stopEvent(event);
} else {
} else if(dojo.isFunction(context.originalHandler)) {
var result = context.originalHandler(event);
if (result == false) {
dojo.stopEvent(event);
}
}
}
};
});
Spring.ValidateAllAdvisor = Spring.DojoValidateAllAdvisor;
Spring.DojoRemotingHandler = function(){};
Spring.DojoRemotingHandler.prototype = {
dojo.declare("Spring.AjaxEventDecoration", Spring.AbstractAjaxEventDecoration, {
constructor : function(config){
this.connection = null;
dojo.mixin(this, config);
},
submitForm : function(/*String */ sourceId, /*String*/formId, /*String*/ processIds, /*String*/renderIds, /*Array*/ params) {
apply : function() {
this.connection = dojo.connect(dojo.byId(this.elementId), this.event, this, "submit");
return this;
},
cleanup : function(){
dojo.disconnect(this.connection);
},
submit : function(event){
if (this.sourceId == ""){
this.sourceId = this.elementId;
}
if(this.formId == ""){
Spring.remoting.getLinkedResource(this.sourceId, this.params, false);
} else {
Spring.remoting.submitForm(this.sourceId, this.formId, this.params);
}
dojo.stopEvent(event);
}
});
dojo.declare("Spring.RemotingHandler", Spring.AbstractRemotingHandler, {
constructor : function(){},
submitForm : function(/*String */ sourceId, /*String*/formId, /*Object*/ params) {
var content = new Object();
for (var key in params) {
content[key] = params[key];
}
var sourceComponent = dojo.byId(sourceId);
content['processIds'] = processIds;
content['renderIds'] = renderIds;
if (sourceComponent != null){
if(sourceComponent.value) {
if(sourceComponent.value != undefined) {
content[sourceId] = sourceComponent.value;
} else {
content[sourceId] = sourceId;
}
}
dojo.forEach(params, function(param){
content[param.name] = param.value;
});
content['ajaxSource'] = sourceId;
if (!content['ajaxSource']) {
content['ajaxSource'] = sourceId;
}
dojo.xhrPost({
@@ -161,18 +160,22 @@ Spring.DojoRemotingHandler.prototype = {
},
getLinkedResource: function(/*String */ linkId, /*boolean*/ modal) {
this.getResource(dojo.byId(linkId).href, modal);
getLinkedResource: function(/*String */ linkId, /*Object*/params, /*boolean*/ modal) {
this.getResource(dojo.byId(linkId).href, params, modal);
},
getResource: function(/*String */ resourceUri, /*boolean*/ modal) {
getResource: function(/*String */ resourceUri, /*Object*/params, /*boolean*/ modal) {
dojo.xhrGet({
url: resourceUri,
content: params,
handleAs: "text",
headers: {"Accept" : "text/html;type=ajax"},
load: this.handleResponse,
error: this.handleError,
@@ -184,14 +187,14 @@ Spring.DojoRemotingHandler.prototype = {
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 redirectURL = ioArgs.xhr.getResponseHeader('Spring-Redirect-URL');
var modalViewHeader = ioArgs.xhr.getResponseHeader('Spring-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);
Spring.remoting.renderURLToModalDialog(redirectURL, ioArgs);
return response;
}
else {
@@ -229,7 +232,7 @@ Spring.DojoRemotingHandler.prototype = {
//For a modal view, just dump the new nodes into a modal dialog
if (modalView) {
Spring.RemotingHandler.renderNodeListToModalDialog(newNodes);
Spring.remoting.renderNodeListToModalDialog(newNodes);
}
else {
@@ -258,7 +261,7 @@ Spring.DojoRemotingHandler.prototype = {
renderURLToModalDialog: function(url, ioArgs) {
url = url + "&"+dojo.objectToQuery(ioArgs.args.content);
Spring.RemotingHandler.getResource(url, true);
Spring.remoting.getResource(url, {}, true);
},
renderNodeListToModalDialog: function(nodes) {
@@ -271,28 +274,21 @@ Spring.DojoRemotingHandler.prototype = {
});
dialog.show();
}
};
});
Spring.RemotingHandler = new Spring.DojoRemotingHandler();
Spring.DojoCommandLinkAdvisor = function(config){
dojo.mixin(this, config);
};
Spring.DojoCommandLinkAdvisor.prototype = {
targetElId : "",
linkHtml : "",
dojo.declare("Spring.CommandLinkDecoration", Spring.AbstractCommandLinkDecoration, {
constructor : function(config){
dojo.mixin(this, config);
},
apply : function(){
var advisedNode = dojo.byId(this.targetElId);
var advisedNode = dojo.byId(this.elementId);
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 = dojo.byId(this.elementId);
}
advisedNode.submitFormFromLink = this.submitFormFromLink;
//return this to support method chaining
@@ -325,8 +321,6 @@ Spring.DojoCommandLinkAdvisor.prototype = {
});
}
}
};
});
Spring.CommandLinkAdvisor = Spring.DojoCommandLinkAdvisor;
dojo.addOnLoad(Spring.applyAdvisors);
dojo.addOnLoad(Spring.initialize);

View File

@@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Spring={};Spring.advisors=[];Spring.advisors.applied=false;Spring.applyAdvisors=function(){if(!Spring.advisors.applied){for(var x=0;x<Spring.advisors.length;x++){Spring.advisors[x].apply();}Spring.advisors.applied=true;}};Spring.validateAll=function(){var _2=true;for(x in Spring.advisors){if(Spring.advisors[x].decorator&&!Spring.advisors[x].validate()){_2=false;}}return _2;};Spring.validateRequired=function(){var _3=true;for(x in Spring.advisors){if(Spring.advisors[x].decorator&&Spring.advisors[x].isRequired()&&!Spring.advisors[x].validate()){_3=false;}}return _3;};Spring.ValidatingFieldAdvisor=function(){};Spring.ValidatingFieldAdvisor.prototype={targetElId:"",decoratorType:"",decorator:null,decoratorAttrs:"",apply:function(){},validate:function(){},isRequired:function(){}};Spring.ValidateAllAdvisor=function(){};Spring.ValidateAllAdvisor.prototype={event:"",targetId:"",connection:null,apply:function(){},cleanup:function(){},handleEvent:function(_4){}};Spring.CommandLinkAdvisor=function(){};Spring.CommandLinkAdvisor.prototype={targetElId:"",linkHtml:"",apply:function(){},submitFormFromLink:function(_5,_6,_7){}};Spring.RemoteEventAdvisor=function(){};Spring.RemoteEventAdvisor.prototype={event:"",targetId:"",sourceId:"",formId:"",processIds:"",renderIds:"",params:[],connection:null,apply:function(){},cleanup:function(){},submit:function(_8){}};Spring.RemotingHandler=function(){};Spring.RemotingHandler.prototype={submitForm:function(_9,_a,_b,_c,_d){},getResource:function(_e,_f,_10){},handleResponse:function(){},handleError:function(){}};
Spring={};Spring.decorations=[];Spring.decorations.applied=false;Spring.initialize=function(){Spring.applyDecorations();Spring.remoting=new Spring.RemotingHandler();};Spring.addDecoration=function(_1){Spring.decorations.push(_1);if(Spring.decorations.applied){_1.apply();}};Spring.applyDecorations=function(){if(!Spring.decorations.applied){for(var x=0;x<Spring.decorations.length;x++){Spring.decorations[x].apply();}Spring.decorations.applied=true;}};Spring.validateAll=function(){var _3=true;for(x in Spring.decorations){if(Spring.decorations[x].widget&&!Spring.decorations[x].validate()){_3=false;}}return _3;};Spring.validateRequired=function(){var _4=true;for(x in Spring.decorations){if(Spring.decorations[x].decorator&&Spring.decorations[x].isRequired()&&!Spring.decorations[x].validate()){_4=false;}}return _4;};Spring.AbstractElementDecoration=function(){};Spring.AbstractElementDecoration.prototype={elementId:"",widgetType:"",widgetModule:"",widget:null,widgetAttrs:{},apply:function(){},validate:function(){},isRequired:function(){}};Spring.AbstractValidateAllDecoration=function(){};Spring.AbstractValidateAllDecoration.prototype={event:"",elementId:"",apply:function(){},cleanup:function(){},handleEvent:function(_5){}};Spring.AbstractCommandLinkDecoration=function(){};Spring.AbstractCommandLinkDecoration.prototype={elementId:"",linkHtml:"",apply:function(){},submitFormFromLink:function(_6,_7,_8){}};Spring.AbstractAjaxEventDecoration=function(){};Spring.AbstractAjaxEventDecoration.prototype={event:"",elementId:"",sourceId:"",formId:"",params:{},apply:function(){},cleanup:function(){},submit:function(_9){}};Spring.AbstractRemotingHandler=function(){};Spring.AbstractRemotingHandler.prototype={submitForm:function(_a,_b,_c){},getLinkedResource:function(_d,_e,_f){},getResource:function(_10,_11,_12){},handleResponse:function(){},handleError:function(){}};

View File

@@ -15,24 +15,36 @@
*/
Spring = {};
Spring.advisors = [];
Spring.decorations = [];
Spring.advisors.applied = false;
Spring.decorations.applied = false;
Spring.initialize = function(){
Spring.applyDecorations();
Spring.remoting = new Spring.RemotingHandler();
};
Spring.addDecoration = function(/*Object*/decoration){
Spring.decorations.push(decoration);
if(Spring.decorations.applied) {
decoration.apply();
}
};
Spring.applyAdvisors = function(){
if (!Spring.advisors.applied) {
for (var x=0; x<Spring.advisors.length; x++) {
Spring.advisors[x].apply();
Spring.applyDecorations = function(){
if (!Spring.decorations.applied) {
for (var x=0; x<Spring.decorations.length; x++) {
Spring.decorations[x].apply();
}
Spring.advisors.applied = true;
Spring.decorations.applied = true;
}
};
Spring.validateAll = function(){
var valid = true;
for(x in Spring.advisors) {
if (Spring.advisors[x].decorator &&
!Spring.advisors[x].validate()) {
for(x in Spring.decorations) {
if (Spring.decorations[x].widget &&
!Spring.decorations[x].validate()) {
valid = false;
}
}
@@ -41,23 +53,24 @@ Spring.validateAll = function(){
Spring.validateRequired = function(){
var valid = true;
for(x in Spring.advisors) {
if(Spring.advisors[x].decorator &&
Spring.advisors[x].isRequired() &&
!Spring.advisors[x].validate())
for(x in Spring.decorations) {
if(Spring.decorations[x].decorator &&
Spring.decorations[x].isRequired() &&
!Spring.decorations[x].validate())
valid = false;
}
return valid;
};
Spring.ValidatingFieldAdvisor = function(){};
Spring.AbstractElementDecoration = function(){};
Spring.ValidatingFieldAdvisor.prototype = {
Spring.AbstractElementDecoration.prototype = {
targetElId : "",
decoratorType : "",
decorator : null,
decoratorAttrs : "",
elementId : "",
widgetType : "",
widgetModule : "",
widget : null,
widgetAttrs : {},
apply : function(){},
@@ -66,13 +79,12 @@ Spring.ValidatingFieldAdvisor.prototype = {
isRequired : function(){}
};
Spring.ValidateAllAdvisor = function(){};
Spring.AbstractValidateAllDecoration = function(){};
Spring.ValidateAllAdvisor.prototype = {
Spring.AbstractValidateAllDecoration.prototype = {
event : "",
targetId : "",
connection : null,
elementId : "",
apply : function() {},
@@ -81,11 +93,11 @@ Spring.ValidateAllAdvisor.prototype = {
handleEvent : function(event){}
};
Spring.CommandLinkAdvisor = function(){};
Spring.AbstractCommandLinkDecoration = function(){};
Spring.CommandLinkAdvisor.prototype = {
Spring.AbstractCommandLinkDecoration.prototype = {
targetElId : "",
elementId : "",
linkHtml : "",
apply : function(){},
@@ -93,18 +105,15 @@ Spring.CommandLinkAdvisor.prototype = {
submitFormFromLink : function(/*String*/ formId, /*String*/ sourceId, /*Array of name,value params*/ params){}
};
Spring.RemoteEventAdvisor = function(){};
Spring.AbstractAjaxEventDecoration = function(){};
Spring.RemoteEventAdvisor.prototype = {
Spring.AbstractAjaxEventDecoration.prototype = {
event : "",
targetId : "",
elementId : "",
sourceId : "",
formId : "",
processIds : "",
renderIds : "",
params : [],
connection : null,
params : {},
apply : function(){},
@@ -113,13 +122,15 @@ Spring.RemoteEventAdvisor.prototype = {
submit : function(event){}
};
Spring.RemotingHandler = function(){};
Spring.AbstractRemotingHandler = function(){};
Spring.RemotingHandler.prototype = {
Spring.AbstractRemotingHandler.prototype = {
submitForm : function(/*String */ sourceId, /*String*/formId, /*String*/ processIds, /*String*/renderIds, /*Array*/ params){},
submitForm : function(/*String */ sourceId, /*String*/formId, /*Object*/ params){},
getResource : function(/*String */ sourceId, /*String*/ processIds, /*String*/renderIds) {},
getLinkedResource: function(/*String */ linkId, /*Object*/params, /*boolean*/ modal) {},
getResource : function(/*String */ resourceUri, /*Object*/params, /*boolean*/ modal) {},
handleResponse : function() {},

View File

@@ -8,7 +8,6 @@ import javax.servlet.ServletContext;
import junit.framework.TestCase;
import org.springframework.js.resource.ResourceServlet;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletConfig;
@@ -60,6 +59,14 @@ public class ResourceServletTests extends TestCase {
assertEquals(404, response.getStatus());
}
public final void testExecute_ProtectedPath() throws Exception {
String requestPath = "/WEB-INF/web.xml";
request.setPathInfo(requestPath);
servlet.doGet(request, response);
assertEquals(404, response.getStatus());
}
private class ResourceTestMockServletContext extends MockServletContext {
public String getMimeType(String filePath) {