SWF-451 - Introduce a "Spring Javascript" javascript abstraction framework usable by both JSF and MVC environments.
SWF-454 - Create a Dojo 1.0 implementation of Spring Javascript
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
SpringFaces = {};
|
||||
|
||||
SpringFaces.advisors = [];
|
||||
|
||||
SpringFaces.advisorsApplied = false;
|
||||
|
||||
SpringFaces.applyAdvisors = function(){
|
||||
if (!SpringFaces.advisorsApplied) {
|
||||
for (var x=0; x<SpringFaces.advisors.length; x++) {
|
||||
SpringFaces.advisors[x].apply();
|
||||
}
|
||||
SpringFaces.advisorsApplied = true;
|
||||
}
|
||||
};
|
||||
|
||||
SpringFaces.validateAll = function(){
|
||||
var valid = true;
|
||||
for(x in SpringFaces.advisors) {
|
||||
if (SpringFaces.advisors[x].decorator &&
|
||||
!SpringFaces.advisors[x].validate()) {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
};
|
||||
@@ -1,252 +0,0 @@
|
||||
SpringUI.DojoValidatingFieldAdvisor = function(config){
|
||||
|
||||
dojo.mixin(this, config);
|
||||
};
|
||||
|
||||
SpringUI.DojoValidatingFieldAdvisor.prototype = {
|
||||
|
||||
targetElId : "",
|
||||
decoratorType : "",
|
||||
decorator : null,
|
||||
decoratorAttrs : "",
|
||||
|
||||
apply : function(){
|
||||
|
||||
this.decorator = eval("new "+ this.decoratorType + "(" + this.decoratorAttrs +", dojo.byId('"+this.targetElId+"'));" );
|
||||
this.decorator.startup();
|
||||
|
||||
//return this to support method chaining
|
||||
return this;
|
||||
},
|
||||
|
||||
validate : function(){
|
||||
var isValid = this.decorator.isValid(false);
|
||||
if (!isValid) {
|
||||
this.decorator.state = "Error";
|
||||
this.decorator._setStateClass();
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
};
|
||||
|
||||
SpringUI.ValidatingFieldAdvisor = SpringUI.DojoValidatingFieldAdvisor;
|
||||
|
||||
SpringUI.DojoRemoteEventAdvisor = function(config){
|
||||
dojo.mixin(this, config);
|
||||
};
|
||||
|
||||
SpringUI.DojoRemoteEventAdvisor.prototype = {
|
||||
|
||||
event : "",
|
||||
targetId : "",
|
||||
sourceId : "",
|
||||
formId : "",
|
||||
processIds : "",
|
||||
renderIds : "",
|
||||
params : [],
|
||||
connection : null,
|
||||
|
||||
apply : function() {
|
||||
connection = dojo.connect(dojo.byId(this.targetId), this.event, this, "submit");
|
||||
return this;
|
||||
},
|
||||
|
||||
cleanup : function(){
|
||||
dojo.disconnect(this.connection);
|
||||
},
|
||||
|
||||
submit : function(event){
|
||||
if (this.sourceId == ""){
|
||||
this.sourceId = this.targetId;
|
||||
}
|
||||
if(this.formId == ""){
|
||||
SpringUI.RemotingHandler.getResource(this.sourceId, this.processIds, this.renderIds);
|
||||
} else {
|
||||
SpringUI.RemotingHandler.submitForm(this.sourceId, this.formId, this.processIds, this.renderIds, this.params);
|
||||
}
|
||||
dojo.stopEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
SpringUI.RemoteEventAdvisor = SpringUI.DojoRemoteEventAdvisor;
|
||||
|
||||
SpringUI.DojoRemotingHandler = function(){};
|
||||
|
||||
SpringUI.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[sourceComponent.name] = sourceComponent.value;
|
||||
} else {
|
||||
content[sourceComponent.name] = 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
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
getResource: function(/*String */ sourceId, /*String*/ processIds, /*String*/renderIds) {
|
||||
var content = new Object();
|
||||
var sourceComponent = dojo.byId(sourceId);
|
||||
content['processIds'] = processIds;
|
||||
content['renderIds'] = renderIds;
|
||||
content['ajaxSource'] = sourceId;
|
||||
|
||||
dojo.xhrGet({
|
||||
|
||||
url: sourceComponent.href,
|
||||
|
||||
content: content,
|
||||
|
||||
handleAs: "text",
|
||||
|
||||
headers: {"Accept" : "text/html;type=ajax"},
|
||||
|
||||
load: this.handleResponse,
|
||||
|
||||
error: this.handleError
|
||||
});
|
||||
},
|
||||
|
||||
handleResponse: function(response, ioArgs) {
|
||||
//alert("handling the 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();
|
||||
|
||||
//Insert the new DOM nodes and update the Form's action URL
|
||||
newNodes.forEach(function(item) {
|
||||
if (item.id == 'flowExecutionUrl'){
|
||||
dojo.query("form").forEach(function (formNode) {
|
||||
formNode.action = item.firstChild.nodeValue;
|
||||
});
|
||||
} else 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) {
|
||||
//alert("handling an error");
|
||||
console.error("HTTP status code: ", ioArgs.xhr.status);
|
||||
return response;
|
||||
}
|
||||
};
|
||||
|
||||
SpringUI.RemotingHandler = new SpringUI.DojoRemotingHandler();
|
||||
|
||||
SpringUI.DojoSubmitLinkAdvisor = function(config){
|
||||
dojo.mixin(this, config);
|
||||
};
|
||||
|
||||
SpringUI.DojoSubmitLinkAdvisor.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, "SpringUILinkInput");
|
||||
dojo.place(nodeToAdd, formNode, "last");
|
||||
});
|
||||
|
||||
if ((formNode.onsubmit ? !formNode.onsubmit() : false) || !formNode.submit()) {
|
||||
dojo.forEach(addedNodes, function(hiddenNode){
|
||||
formNode.removeChild(hiddenNode);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SpringUI.SubmitLinkAdvisor = SpringUI.DojoSubmitLinkAdvisor;
|
||||
|
||||
dojo.addOnLoad(SpringUI.applyAdvisors);
|
||||
@@ -1,85 +0,0 @@
|
||||
SpringUI = {};
|
||||
|
||||
SpringUI.advisors = [];
|
||||
|
||||
SpringUI.advisorsApplied = false;
|
||||
|
||||
SpringUI.applyAdvisors = function(){
|
||||
if (!SpringUI.advisorsApplied) {
|
||||
for (var x=0; x<SpringUI.advisors.length; x++) {
|
||||
SpringUI.advisors[x].apply();
|
||||
}
|
||||
SpringUI.advisorsApplied = true;
|
||||
}
|
||||
};
|
||||
|
||||
SpringUI.validateAll = function(){
|
||||
var valid = true;
|
||||
for(x in SpringUI.advisors) {
|
||||
if (SpringUI.advisors[x].decorator &&
|
||||
!SpringUI.advisors[x].validate()) {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
};
|
||||
|
||||
SpringUI.validateRequired = function(){
|
||||
var valid = true;
|
||||
for(x in SpringUI.advisors) {
|
||||
if(SpringUI.advisors[x].decorator &&
|
||||
SpringUI.advisors[x].isRequired() &&
|
||||
!SpringUI.advisors[x].validate())
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
};
|
||||
|
||||
SpringUI.ValidatingFieldAdvisor = function(){};
|
||||
|
||||
SpringUI.ValidatingFieldAdvisor.prototype = {
|
||||
|
||||
targetElId : "",
|
||||
decoratorType : "",
|
||||
decorator : null,
|
||||
decoratorAttrs : "",
|
||||
|
||||
apply : function(){},
|
||||
|
||||
validate : function(){},
|
||||
|
||||
isRequired : function(){}
|
||||
};
|
||||
|
||||
SpringUI.RemoteEventAdvisor = function(){};
|
||||
|
||||
SpringUI.RemoteEventAdvisor.prototype = {
|
||||
|
||||
event : "",
|
||||
targetId : "",
|
||||
sourceId : "",
|
||||
formId : "",
|
||||
processIds : "",
|
||||
renderIds : "",
|
||||
params : [],
|
||||
connection : null,
|
||||
|
||||
apply : function(){},
|
||||
|
||||
cleanup : function(){},
|
||||
|
||||
submit : function(event){}
|
||||
};
|
||||
|
||||
SpringUI.RemotingHandler = function(){};
|
||||
|
||||
SpringUI.RemotingHandler.prototype = {
|
||||
|
||||
submitForm : function(/*String */ sourceId, /*String*/formId, /*String*/ processIds, /*String*/renderIds, /*Array*/ params){},
|
||||
|
||||
getResource : function(/*String */ sourceId, /*String*/ processIds, /*String*/renderIds) {},
|
||||
|
||||
handleResponse : function() {},
|
||||
|
||||
handleError : function() {}
|
||||
};
|
||||
@@ -1,9 +1,9 @@
|
||||
SpringFaces.DojoGenericFieldAdvisor = function(config){
|
||||
Spring.DojoValidatingFieldAdvisor = function(config){
|
||||
|
||||
dojo.mixin(this, config);
|
||||
};
|
||||
|
||||
SpringFaces.DojoGenericFieldAdvisor.prototype = {
|
||||
Spring.DojoValidatingFieldAdvisor.prototype = {
|
||||
|
||||
targetElId : "",
|
||||
decoratorType : "",
|
||||
@@ -29,11 +29,13 @@ SpringFaces.DojoGenericFieldAdvisor.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
SpringFaces.DojoAjaxEventAdvisor = function(config){
|
||||
Spring.ValidatingFieldAdvisor = Spring.DojoValidatingFieldAdvisor;
|
||||
|
||||
Spring.DojoRemoteEventAdvisor = function(config){
|
||||
dojo.mixin(this, config);
|
||||
};
|
||||
|
||||
SpringFaces.DojoAjaxEventAdvisor.prototype = {
|
||||
Spring.DojoRemoteEventAdvisor.prototype = {
|
||||
|
||||
event : "",
|
||||
targetId : "",
|
||||
@@ -54,13 +56,15 @@ SpringFaces.DojoAjaxEventAdvisor.prototype = {
|
||||
},
|
||||
|
||||
submit : function(){
|
||||
SpringFaces.AjaxHandler.submitForm(this.sourceId, this.formId, this.processIds, this.renderIds, this.params);
|
||||
Spring.RemotingHandler.submitForm(this.sourceId, this.formId, this.processIds, this.renderIds, this.params);
|
||||
}
|
||||
};
|
||||
|
||||
SpringFaces.DojoAjaxHandler = function(){};
|
||||
Spring.RemoteEventAdvisor = Spring.DojoRemoteEventAdvisor;
|
||||
|
||||
SpringFaces.DojoAjaxHandler.prototype = {
|
||||
Spring.DojoRemotingHandler = function(){};
|
||||
|
||||
Spring.DojoRemotingHandler.prototype = {
|
||||
|
||||
submitForm : function(/*String */ sourceId, /*String*/formId, /*String*/ processIds, /*String*/renderIds, /*Array*/ params) {
|
||||
var content = new Object();
|
||||
@@ -112,7 +116,7 @@ SpringFaces.DojoAjaxHandler.prototype = {
|
||||
if (dojo.isString(redirectURL) && redirectURL.length > 0) {
|
||||
if (modalView) {
|
||||
//render a popup with the new URL
|
||||
SpringFaces.AjaxHandler.renderURLToModalDialog(redirectURL, ioArgs);
|
||||
Spring.RemotingHandler.renderURLToModalDialog(redirectURL, ioArgs);
|
||||
return response;
|
||||
}
|
||||
else {
|
||||
@@ -150,7 +154,7 @@ SpringFaces.DojoAjaxHandler.prototype = {
|
||||
|
||||
//For a modal view, just dump the new nodes into a modal dialog
|
||||
if (modalView) {
|
||||
SpringFaces.AjaxHandler.renderNodeListToModalDialog(newNodes);
|
||||
Spring.RemotingHandler.renderNodeListToModalDialog(newNodes);
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -195,13 +199,13 @@ SpringFaces.DojoAjaxHandler.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
SpringFaces.AjaxHandler = new SpringFaces.DojoAjaxHandler();
|
||||
Spring.RemotingHandler = new Spring.DojoRemotingHandler();
|
||||
|
||||
SpringFaces.DojoCommandLinkAdvisor = function(config){
|
||||
Spring.DojoCommandLinkAdvisor = function(config){
|
||||
dojo.mixin(this, config);
|
||||
};
|
||||
|
||||
SpringFaces.DojoCommandLinkAdvisor.prototype = {
|
||||
Spring.DojoCommandLinkAdvisor.prototype = {
|
||||
|
||||
targetElId : "",
|
||||
|
||||
@@ -221,10 +225,6 @@ SpringFaces.DojoCommandLinkAdvisor.prototype = {
|
||||
return this;
|
||||
},
|
||||
|
||||
validate : function() {
|
||||
//No-op
|
||||
},
|
||||
|
||||
submitFormFromLink : function(/*String*/ formId, /*String*/ sourceId, /*Array of name,value params*/ params){
|
||||
var addedNodes = [];
|
||||
var formNode = dojo.byId(formId);
|
||||
@@ -241,7 +241,7 @@ SpringFaces.DojoCommandLinkAdvisor.prototype = {
|
||||
});
|
||||
|
||||
dojo.forEach(addedNodes, function(nodeToAdd){
|
||||
dojo.addClass(nodeToAdd, "springFacesLinkInput");
|
||||
dojo.addClass(nodeToAdd, "SpringLinkInput");
|
||||
dojo.place(nodeToAdd, formNode, "last");
|
||||
});
|
||||
|
||||
@@ -253,4 +253,6 @@ SpringFaces.DojoCommandLinkAdvisor.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
dojo.addOnLoad(SpringFaces.applyAdvisors);
|
||||
Spring.CommandLinkAdvisor = Spring.DojoCommandLinkAdvisor;
|
||||
|
||||
dojo.addOnLoad(Spring.applyAdvisors);
|
||||
97
spring-faces/src/main/java/META-INF/spring/Spring.js
Normal file
97
spring-faces/src/main/java/META-INF/spring/Spring.js
Normal file
@@ -0,0 +1,97 @@
|
||||
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 valid = true;
|
||||
for(x in Spring.advisors) {
|
||||
if (Spring.advisors[x].decorator &&
|
||||
!Spring.advisors[x].validate()) {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
};
|
||||
|
||||
Spring.validateRequired = function(){
|
||||
var valid = true;
|
||||
for(x in Spring.advisors) {
|
||||
if(Spring.advisors[x].decorator &&
|
||||
Spring.advisors[x].isRequired() &&
|
||||
!Spring.advisors[x].validate())
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
};
|
||||
|
||||
Spring.ValidatingFieldAdvisor = function(){};
|
||||
|
||||
Spring.ValidatingFieldAdvisor.prototype = {
|
||||
|
||||
targetElId : "",
|
||||
decoratorType : "",
|
||||
decorator : null,
|
||||
decoratorAttrs : "",
|
||||
|
||||
apply : function(){},
|
||||
|
||||
validate : function(){},
|
||||
|
||||
isRequired : function(){}
|
||||
};
|
||||
|
||||
Spring.CommandLinkAdvisor = function(){};
|
||||
|
||||
Spring.CommandLinkAdvisor.prototype = {
|
||||
|
||||
targetElId : "",
|
||||
linkHtml : "",
|
||||
|
||||
apply : function(){},
|
||||
|
||||
submitFormFromLink : function(/*String*/ formId, /*String*/ sourceId, /*Array of name,value params*/ params){}
|
||||
};
|
||||
|
||||
Spring.RemoteEventAdvisor = function(){};
|
||||
|
||||
Spring.RemoteEventAdvisor.prototype = {
|
||||
|
||||
event : "",
|
||||
targetId : "",
|
||||
sourceId : "",
|
||||
formId : "",
|
||||
processIds : "",
|
||||
renderIds : "",
|
||||
params : [],
|
||||
connection : null,
|
||||
|
||||
apply : function(){},
|
||||
|
||||
cleanup : function(){},
|
||||
|
||||
submit : function(event){}
|
||||
};
|
||||
|
||||
Spring.RemotingHandler = function(){};
|
||||
|
||||
Spring.RemotingHandler.prototype = {
|
||||
|
||||
submitForm : function(/*String */ sourceId, /*String*/formId, /*String*/ processIds, /*String*/renderIds, /*Array*/ params){},
|
||||
|
||||
getResource : function(/*String */ sourceId, /*String*/ processIds, /*String*/renderIds) {},
|
||||
|
||||
handleResponse : function() {},
|
||||
|
||||
handleError : function() {}
|
||||
};
|
||||
@@ -32,7 +32,7 @@ public class AjaxEventInterceptorRenderer extends DojoRenderer {
|
||||
renderIds = processIds;
|
||||
}
|
||||
StringBuffer script = new StringBuffer();
|
||||
script.append("SpringFaces.advisors.push(new SpringFaces.DojoAjaxEventAdvisor({");
|
||||
script.append("Spring.advisors.push(new Spring.RemoteEventAdvisor({");
|
||||
script.append("event:'" + event + "'");
|
||||
script.append(", targetId: '" + ((UIComponent) component.getChildren().get(0)).getClientId(context) + "'");
|
||||
script.append(", sourceId : '" + component.getClientId(context) + "'");
|
||||
|
||||
@@ -19,7 +19,7 @@ public abstract class BaseDojoParentComponentRenderer extends BaseSpringFacesPar
|
||||
|
||||
private String dijitTheme = "tundra";
|
||||
|
||||
private String springFacesDojoJsResourceUri = "/spring-faces/SpringFaces-Dojo.js";
|
||||
private String springDojoJsResourceUri = "/spring/Spring-Dojo.js";
|
||||
|
||||
private FlowResourceHelper resourceHelper = new FlowResourceHelper();
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class BaseDojoParentComponentRenderer extends BaseSpringFacesPar
|
||||
dojoAttributes.put("djConfig", "parseOnLoad: true");
|
||||
resourceHelper.renderScriptLink(context, dojoJsResourceUri, dojoAttributes);
|
||||
|
||||
resourceHelper.renderScriptLink(context, springFacesDojoJsResourceUri);
|
||||
resourceHelper.renderScriptLink(context, springDojoJsResourceUri);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.springframework.faces.ui.resource.FlowResourceHelper;
|
||||
|
||||
public abstract class BaseSpringFacesParentComponentRenderer extends BaseParentComponentRenderer {
|
||||
|
||||
private String springFacesJsResourceUri = "/spring-faces/SpringFaces.js";
|
||||
private String springJsResourceUri = "/spring/Spring.js";
|
||||
|
||||
private FlowResourceHelper resourceHelper = new FlowResourceHelper();
|
||||
|
||||
@@ -17,6 +17,6 @@ public abstract class BaseSpringFacesParentComponentRenderer extends BaseParentC
|
||||
|
||||
super.encodeBegin(context, component);
|
||||
|
||||
resourceHelper.renderScriptLink(context, springFacesJsResourceUri);
|
||||
resourceHelper.renderScriptLink(context, springJsResourceUri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DojoAdvisorRenderer extends DojoRenderer {
|
||||
|
||||
writer.startElement(SCRIPT_ELEMENT, component);
|
||||
StringBuffer script = new StringBuffer();
|
||||
script.append(" SpringFaces.advisors.push(new SpringFaces.DojoGenericFieldAdvisor({ ");
|
||||
script.append(" Spring.advisors.push(new Spring.ValidatingFieldAdvisor({ ");
|
||||
script.append(" targetElId : '" + advisedChild.getClientId(context) + "', ");
|
||||
script.append(" msgElId : '" + advisedChild.getClientId(context) + ":msg', ");
|
||||
script.append(" decoratorType : '" + ((DojoAdvisor) component).getDojoComponentType() + "', ");
|
||||
|
||||
@@ -34,7 +34,7 @@ public class DojoRenderer extends SpringFacesRenderer {
|
||||
|
||||
private String dijitTheme = "tundra";
|
||||
|
||||
private String springFacesDojoJsResourceUri = "/spring-faces/SpringFaces-Dojo.js";
|
||||
private String springDojoJsResourceUri = "/spring/Spring-Dojo.js";
|
||||
|
||||
private FlowResourceHelper resourceHelper = new FlowResourceHelper();
|
||||
|
||||
@@ -49,6 +49,6 @@ public class DojoRenderer extends SpringFacesRenderer {
|
||||
dojoAttributes.put("djConfig", "parseOnLoad: true");
|
||||
resourceHelper.renderScriptLink(context, dojoJsResourceUri, dojoAttributes);
|
||||
|
||||
resourceHelper.renderScriptLink(context, springFacesDojoJsResourceUri);
|
||||
resourceHelper.renderScriptLink(context, springDojoJsResourceUri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ExtAdvisorRenderer extends ExtJsRenderer {
|
||||
|
||||
writer.startElement(SCRIPT_ELEMENT, component);
|
||||
StringBuffer script = new StringBuffer();
|
||||
script.append(" SpringFaces.advisors.push(new SpringFaces.ExtGenericFieldAdvisor({ ");
|
||||
script.append(" Spring.advisors.push(new Spring.ValidatingFieldAdvisor({ ");
|
||||
script.append(" targetElId : '" + advisedChild.getClientId(context) + "', ");
|
||||
script.append(" msgElId : '" + advisedChild.getClientId(context) + ":msg', ");
|
||||
script.append(" decoratorType : '" + ((ExtAdvisor) component).getExtComponentType() + "', ");
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ExtJsRenderer extends SpringFacesRenderer {
|
||||
|
||||
private static final String EXT_SCRIPT = "/ext/ext.js";
|
||||
|
||||
private static final String SPRING_FACES_EXT_SCRIPT = "/spring-faces/SpringFaces-Ext.js";
|
||||
private static final String SPRING_EXT_SCRIPT = "/spring/Spring-Ext.js";
|
||||
|
||||
private FlowResourceHelper resourceHelper = new FlowResourceHelper();
|
||||
|
||||
@@ -46,6 +46,6 @@ public class ExtJsRenderer extends SpringFacesRenderer {
|
||||
resourceHelper.renderScriptLink(context, EXT_SCRIPT);
|
||||
}
|
||||
|
||||
resourceHelper.renderScriptLink(context, SPRING_FACES_EXT_SCRIPT);
|
||||
resourceHelper.renderScriptLink(context, SPRING_EXT_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class ProgressiveCommandButtonRenderer extends BaseDojoParentComponentRen
|
||||
if (!StringUtils.hasText(renderIds)) {
|
||||
renderIds = processIds;
|
||||
}
|
||||
onclick.append("SpringFaces.AjaxHandler.submitForm('" + component.getClientId(context) + "', ");
|
||||
onclick.append("Spring.RemotingHandler.submitForm('" + component.getClientId(context) + "', ");
|
||||
onclick.append("'" + RendererUtils.getFormId(context, component) + "', ");
|
||||
onclick.append("'" + processIds + "', '" + renderIds + "', " + encodeParams(context, component)
|
||||
+ "); return false;");
|
||||
|
||||
@@ -107,8 +107,7 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
|
||||
|
||||
advisorParams.append("}");
|
||||
StringBuffer advisorScript = new StringBuffer();
|
||||
advisorScript.append("SpringFaces.advisors.push(new SpringFaces.DojoCommandLinkAdvisor("
|
||||
+ advisorParams.toString() + ")");
|
||||
advisorScript.append("Spring.advisors.push(new Spring.CommandLinkAdvisor(" + advisorParams.toString() + ")");
|
||||
// Apply the advisor immediately if this is an AJAX request
|
||||
if (JsfUtils.isAsynchronousFlowRequest()) {
|
||||
advisorScript.append(".apply()");
|
||||
|
||||
@@ -25,13 +25,13 @@ import org.springframework.faces.ui.resource.FlowResourceHelper;
|
||||
|
||||
public class SpringFacesRenderer extends Renderer {
|
||||
|
||||
private String springFacesJsResourceUri = "/spring-faces/SpringFaces.js";
|
||||
private String springJsResourceUri = "/spring/Spring.js";
|
||||
|
||||
private FlowResourceHelper resourceHelper = new FlowResourceHelper();
|
||||
|
||||
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
|
||||
|
||||
resourceHelper.renderScriptLink(context, springFacesJsResourceUri);
|
||||
resourceHelper.renderScriptLink(context, springJsResourceUri);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ValidateAllRenderer extends SpringFacesRenderer {
|
||||
+ "');");
|
||||
script.append(" var " + handlerVar + " = " + elementVar + ".onclick;");
|
||||
script.append(elementVar + ".onclick" + " = function(){");
|
||||
script.append(" if(!SpringFaces.validateAll()) return false; ");
|
||||
script.append(" if(!Spring.validateAll()) return false; ");
|
||||
script.append(handlerVar + "();");
|
||||
script.append("};");
|
||||
|
||||
|
||||
@@ -117,6 +117,10 @@ public class ResourceServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
private URL getRequestResourceURL(String localResourcePath) throws MalformedURLException {
|
||||
if (localResourcePath.contains("/resources")){
|
||||
localResourcePath = localResourcePath.replaceAll("/resources", "");
|
||||
}
|
||||
|
||||
String jarResourcePath = "META-INF" + localResourcePath;
|
||||
|
||||
URL resource;
|
||||
|
||||
Reference in New Issue
Block a user