-Changed Dojo renderers to configure Dojo with parseOnLoad=true
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package org.springframework.faces.ui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
@@ -11,6 +13,8 @@ public abstract class BaseDojoParentComponentRenderer extends BaseSpringFacesPar
|
||||
|
||||
private String dojoJsResourceUri = "/dojo/dojo.js";
|
||||
|
||||
private String dojoCssResourceUri = "/dojo/resources/dojo.css";
|
||||
|
||||
private String dijitThemePath = "/dijit/themes/";
|
||||
|
||||
private String dijitTheme = "tundra";
|
||||
@@ -20,13 +24,16 @@ public abstract class BaseDojoParentComponentRenderer extends BaseSpringFacesPar
|
||||
private FlowResourceHelper resourceHelper = new FlowResourceHelper();
|
||||
|
||||
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
|
||||
super.encodeBegin(context, component);
|
||||
|
||||
resourceHelper.renderStyleLink(context, dojoCssResourceUri);
|
||||
resourceHelper.renderStyleLink(context, dijitThemePath + dijitTheme + "/" + dijitTheme + ".css");
|
||||
|
||||
resourceHelper.renderScriptLink(context, dojoJsResourceUri);
|
||||
Map dojoAttributes = new HashMap();
|
||||
dojoAttributes.put("djConfig", "parseOnLoad: true");
|
||||
resourceHelper.renderScriptLink(context, dojoJsResourceUri, dojoAttributes);
|
||||
|
||||
resourceHelper.renderScriptLink(context, springFacesDojoJsResourceUri);
|
||||
|
||||
super.encodeBegin(context, component);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ public abstract class BaseSpringFacesParentComponentRenderer extends BaseParentC
|
||||
|
||||
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
|
||||
|
||||
resourceHelper.renderScriptLink(context, springFacesJsResourceUri);
|
||||
|
||||
super.encodeBegin(context, component);
|
||||
|
||||
resourceHelper.renderScriptLink(context, springFacesJsResourceUri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
package org.springframework.faces.ui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
@@ -26,6 +28,8 @@ public class DojoRenderer extends SpringFacesRenderer {
|
||||
|
||||
private String dojoJsResourceUri = "/dojo/dojo.js";
|
||||
|
||||
private String dojoCssResourceUri = "/dojo/resources/dojo.css";
|
||||
|
||||
private String dijitThemePath = "/dijit/themes/";
|
||||
|
||||
private String dijitTheme = "tundra";
|
||||
@@ -38,9 +42,12 @@ public class DojoRenderer extends SpringFacesRenderer {
|
||||
|
||||
super.encodeBegin(context, component);
|
||||
|
||||
resourceHelper.renderStyleLink(context, dojoCssResourceUri);
|
||||
resourceHelper.renderStyleLink(context, dijitThemePath + dijitTheme + "/" + dijitTheme + ".css");
|
||||
|
||||
resourceHelper.renderScriptLink(context, dojoJsResourceUri);
|
||||
Map dojoAttributes = new HashMap();
|
||||
dojoAttributes.put("djConfig", "parseOnLoad: true");
|
||||
resourceHelper.renderScriptLink(context, dojoJsResourceUri, dojoAttributes);
|
||||
|
||||
resourceHelper.renderScriptLink(context, springFacesDojoJsResourceUri);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.springframework.faces.ui.resource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
@@ -31,6 +34,17 @@ public class FlowResourceHelper {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void renderScriptLink(FacesContext facesContext, String scriptPath) throws IOException {
|
||||
renderScriptLink(facesContext, scriptPath, Collections.EMPTY_MAP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a <code><script/></code> tag for a given script resource.
|
||||
* @param facesContext
|
||||
* @param scriptPath
|
||||
* @param attributes - a map of additional attributes to render on the script tag
|
||||
* @throws IOException
|
||||
*/
|
||||
public void renderScriptLink(FacesContext facesContext, String scriptPath, Map attributes) throws IOException {
|
||||
|
||||
if (alreadyRendered(facesContext, scriptPath)) {
|
||||
return;
|
||||
@@ -44,6 +58,12 @@ public class FlowResourceHelper {
|
||||
|
||||
writer.writeAttribute("type", "text/javascript", null);
|
||||
|
||||
Iterator i = attributes.keySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
String key = (String) i.next();
|
||||
writer.writeAttribute(key, attributes.get(key), null);
|
||||
}
|
||||
|
||||
FlowDefinitionRequestInfo requestInfo = new FlowDefinitionRequestInfo("resources", new RequestPath(scriptPath),
|
||||
null, null);
|
||||
String src = requestContext.getExternalContext().buildFlowDefinitionUrl(requestInfo);
|
||||
|
||||
Reference in New Issue
Block a user