You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/04/05 22:31:59 UTC
svn commit: r391791 - in
/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo:
DojoConfig.java DojoInitializer.java DojoInitializerRenderer.java
DojoInitializerTag.java DojoResourceLoader.java DojoUtils.java
Author: werpu
Date: Wed Apr 5 13:31:58 2006
New Revision: 391791
URL: http://svn.apache.org/viewcvs?rev=391791&view=rev
Log:
some code cleanup
fixed a bug, requires and provides do not allow blanks in the statement
a trim is performed before rendering now (someone in a project
ran exactly into this bug)
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoConfig.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerTag.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoResourceLoader.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoConfig.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoConfig.java?rev=391791&r1=391790&r2=391791&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoConfig.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoConfig.java Wed Apr 5 13:31:58 2006
@@ -18,181 +18,175 @@
import java.io.Serializable;
+
/**
* Dojo configuration holder helper
* this is a helper class to generate
* a dojo configuration
- * if a null value is set the toString
+ * if a null value is set the toString
* ignores the djconfig
- *
+ *
* the toString method generates a full djconfig
- *
+ *
* Warning if you adjust the dojo config params
* do it before rendering
* because this stuff is shared in the request
* as a singleton value in normal circumstances!
- *
+ *
* (unless you want to influence the dojo config
* seriously afterwards please, follow this guideline
* use the decode phase or something similar if not available)
- *
+ *
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class DojoConfig implements Serializable
-{
+public class DojoConfig implements Serializable {
+
/**
- *
+ *
*/
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
+ private static final String CONFIG_FOOTER = "}; \n";
+ private static final String CONFIG_HEADER = "var djConfig = { \n";
+ public static String ATTR_DOJO_TYPE = "dojoType";
+ Boolean _allowQueryConfig = null;
+ String _baseScriptUri = null;
+ Boolean _bindEncoding = null;
+ Boolean _debug = null;
+ Boolean _debugAtAllCosts = null;
+ String _debugContainerId = null;
+ Boolean _ignoreClassNames = null;
+ Boolean _ioSendTransport = null;
+ Boolean _parseWidgets = null;
+ Boolean _preventBackButtonFix = null;
+ String _searchIds = null;
+ //getters and setters for the djconfig
+ public Boolean getAllowQueryConfig() {
+ return _allowQueryConfig;
+ }
- private static final String CONFIG_FOOTER = "}; \n";
+ public String getBaseScriptUri() {
+ return _baseScriptUri;
+ }
+ public Boolean getBindEncoding() {
+ return _bindEncoding;
+ }
- private static final String CONFIG_HEADER = "var djConfig = { \n";
+ public Boolean getDebug() {
+ return _debug;
+ }
+ public Boolean getDebugAtAllCosts() {
+ return _debugAtAllCosts;
+ }
- public static String ATTR_DOJO_TYPE = "dojoType";
-
-
- Boolean _ioSendTransport = null;
- Boolean _debug = null;
- String _baseScriptUri = null;
- Boolean _allowQueryConfig = null;
- String _debugContainerId = null;
- String _searchIds = null;
- Boolean _parseWidgets = null;
- Boolean _bindEncoding = null;
- Boolean _ignoreClassNames = null;
- Boolean _preventBackButtonFix = null;
- Boolean _debugAtAllCosts = null;
-
- private final void createConfigEntry(StringBuffer target, String name, Object toCheck) {
- if(toCheck == null) return;
- if(target.indexOf(":") != -1)
- target.append(",\n");
- target.append(name);
- target.append(":");
- target.append(toCheck);
- }
-
- /**
- * returns a valid djconfig string
- */
- public String toString() {
-
- StringBuffer configBuilder = new StringBuffer(128);
- configBuilder.append(CONFIG_HEADER);
+ public String getDebugContainerId() {
+ return _debugContainerId;
+ }
- createConfigEntry(configBuilder, "ioSendTransport", _ioSendTransport);
- createConfigEntry(configBuilder, "isDebug", _debug);
- createConfigEntry(configBuilder, "baseScriptUri", _baseScriptUri);
- createConfigEntry(configBuilder, "allowQueryConfig", _allowQueryConfig);
- createConfigEntry(configBuilder, "debugContainerId", _debugContainerId);
- createConfigEntry(configBuilder, "searchIds", _searchIds);
- createConfigEntry(configBuilder, "parseWidgets", _parseWidgets);
- createConfigEntry(configBuilder, "bindEncoding", _bindEncoding);
- createConfigEntry(configBuilder, "ignoreClassNames", _ignoreClassNames);
- createConfigEntry(configBuilder, "preventBackButtonFix", _preventBackButtonFix);
- createConfigEntry(configBuilder, "debugAtAllCosts", _debugAtAllCosts);
-
- configBuilder.append("\n");
- configBuilder.append(CONFIG_FOOTER);
+ public Boolean getIgnoreClassNames() {
+ return _ignoreClassNames;
+ }
- return configBuilder.toString();
+ public Boolean getIoSendTransport() {
+ return _ioSendTransport;
}
-
- //getters and setters for the djconfig
- public Boolean getAllowQueryConfig()
- {
- return _allowQueryConfig;
+
+ public Boolean getParseWidgets() {
+ return _parseWidgets;
}
- public void setAllowQueryConfig(Boolean allowQueryConfig)
- {
- this._allowQueryConfig = allowQueryConfig;
+
+ public Boolean getPreventBackButtonFix() {
+ return _preventBackButtonFix;
}
- public String getBaseScriptUri()
- {
- return _baseScriptUri;
+
+ public String getSearchIds() {
+ return _searchIds;
}
- public void setBaseScriptUri(String baseScriptUri)
- {
- this._baseScriptUri = baseScriptUri;
+
+ public void setAllowQueryConfig(Boolean allowQueryConfig) {
+ this._allowQueryConfig = allowQueryConfig;
}
- public Boolean getBindEncoding()
- {
- return _bindEncoding;
+
+ public void setBaseScriptUri(String baseScriptUri) {
+ this._baseScriptUri = baseScriptUri;
}
- public void setBindEncoding(Boolean bindEncoding)
- {
+
+ public void setBindEncoding(Boolean bindEncoding) {
this._bindEncoding = bindEncoding;
}
- public Boolean getDebug()
- {
- return _debug;
- }
- public void setDebug(Boolean debug)
- {
+
+ public void setDebug(Boolean debug) {
this._debug = debug;
}
- public String getDebugContainerId()
- {
- return _debugContainerId;
+
+ public void setDebugAtAllCosts(Boolean debugAtAllCosts) {
+ this._debugAtAllCosts = debugAtAllCosts;
}
- public void setDebugContainerId(String debugContainerId)
- {
+
+ public void setDebugContainerId(String debugContainerId) {
this._debugContainerId = debugContainerId;
}
- public Boolean getIgnoreClassNames()
- {
- return _ignoreClassNames;
- }
- public void setIgnoreClassNames(Boolean ignoreClassNames)
- {
+
+ public void setIgnoreClassNames(Boolean ignoreClassNames) {
this._ignoreClassNames = ignoreClassNames;
}
- public Boolean getIoSendTransport()
- {
- return _ioSendTransport;
- }
- public void setIoSendTransport(Boolean ioSendTransport)
- {
+
+ public void setIoSendTransport(Boolean ioSendTransport) {
this._ioSendTransport = ioSendTransport;
}
- public Boolean getParseWidgets()
- {
- return _parseWidgets;
- }
- public void setParseWidgets(Boolean parseWidgets)
- {
+
+ public void setParseWidgets(Boolean parseWidgets) {
this._parseWidgets = parseWidgets;
}
- public Boolean getPreventBackButtonFix()
- {
- return _preventBackButtonFix;
- }
- public void setPreventBackButtonFix(Boolean preventBackButtonFix)
- {
+
+ public void setPreventBackButtonFix(Boolean preventBackButtonFix) {
this._preventBackButtonFix = preventBackButtonFix;
}
- public String getSearchIds()
- {
- return _searchIds;
- }
- public void setSearchIds(String searchIds)
- {
+
+ public void setSearchIds(String searchIds) {
this._searchIds = searchIds;
}
- public Boolean getDebugAtAllCosts()
- {
- return _debugAtAllCosts;
+ /**
+ * returns a valid djconfig string
+ */
+ public String toString() {
+
+ StringBuffer configBuilder = new StringBuffer(128);
+ configBuilder.append(CONFIG_HEADER);
+
+ createConfigEntry(configBuilder, "ioSendTransport", _ioSendTransport);
+ createConfigEntry(configBuilder, "isDebug", _debug);
+ createConfigEntry(configBuilder, "baseScriptUri", _baseScriptUri);
+ createConfigEntry(configBuilder, "allowQueryConfig", _allowQueryConfig);
+ createConfigEntry(configBuilder, "debugContainerId", _debugContainerId);
+ createConfigEntry(configBuilder, "searchIds", _searchIds);
+ createConfigEntry(configBuilder, "parseWidgets", _parseWidgets);
+ createConfigEntry(configBuilder, "bindEncoding", _bindEncoding);
+ createConfigEntry(configBuilder, "ignoreClassNames", _ignoreClassNames);
+ createConfigEntry(configBuilder, "preventBackButtonFix", _preventBackButtonFix);
+ createConfigEntry(configBuilder, "debugAtAllCosts", _debugAtAllCosts);
+
+ configBuilder.append("\n");
+ configBuilder.append(CONFIG_FOOTER);
+
+ return configBuilder.toString();
}
- public void setDebugAtAllCosts(Boolean debugAtAllCosts)
- {
- this._debugAtAllCosts = debugAtAllCosts;
+ private final void createConfigEntry(StringBuffer target, String name, Object toCheck) {
+
+ if (toCheck == null)
+ return;
+
+ if (target.indexOf(":") != -1)
+ target.append(",\n");
+
+ target.append(name);
+ target.append(":");
+ target.append(toCheck);
}
- }
+}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializer.java?rev=391791&r1=391790&r2=391791&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializer.java Wed Apr 5 13:31:58 2006
@@ -19,172 +19,183 @@
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
+
/**
* Default component for the dojo intializer
- *
+ *
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class DojoInitializer extends UIOutput
-{
- DojoConfig _dojoConfig = new DojoConfig();
- String _require = null;
- String _provide = null;
- Boolean _debugConsole = null;
- Boolean _expanded = null;
-
- //we handle that specifically to speed things up (we do not want an NxN runtime complexity via enforced
- //reflection in the utils
- boolean dojoConfigParamSet = false;
+public class DojoInitializer extends UIOutput {
public static final String COMPONENT_TYPE = "org.apache.myfaces.DojoInitializer";
public static final String DEFAULT_RENDERER_TYPE = DojoInitializerRenderer.RENDERER_TYPE;
public static final String COMPONENT_FAMILY = "javax.faces.Output";
+ Boolean _debugConsole = null;
+ DojoConfig _dojoConfig = new DojoConfig();
+ Boolean _expanded = null;
+ String _provide = null;
+ String _require = null;
+
+ //we handle that specifically to speed things up (we do not want an NxN runtime complexity via enforced
+ //reflection in the utils
+ boolean dojoConfigParamSet = false;
- public DojoInitializer()
- {
+ public DojoInitializer() {
super();
setRendererType(DEFAULT_RENDERER_TYPE);
}
- public String getRendererType()
- {
- return DojoInitializerRenderer.RENDERER_TYPE;
+ public Boolean getAllowQueryConfig() {
+ return _dojoConfig.getAllowQueryConfig();
}
- public String getFamily()
- {
- return COMPONENT_FAMILY;
+ public String getBaseScriptUri() {
+ return _dojoConfig.getBaseScriptUri();
}
- public String getComponentType()
- {
- return COMPONENT_TYPE;
+ public Boolean getBindEncoding() {
+ return _dojoConfig.getBindEncoding();
}
- public Object getValue()
- {
- return "DojoInitializers";
+ public String getComponentType() {
+ return COMPONENT_TYPE;
}
- public void restoreState(FacesContext context, Object state)
- {
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
- _dojoConfig.setAllowQueryConfig((Boolean) values[1]);
- _dojoConfig.setBaseScriptUri((String) values[2]);
- _dojoConfig.setBindEncoding((Boolean) values[3]);
- _dojoConfig.setDebug((Boolean) values[4]);
- _dojoConfig.setDebugContainerId((String) values[5]);
- _dojoConfig.setIgnoreClassNames((Boolean) values[6]);
- _dojoConfig.setIoSendTransport((Boolean) values[7]);
- _dojoConfig.setParseWidgets((Boolean) values[8]);
- _dojoConfig.setPreventBackButtonFix((Boolean) values[9]);
- _dojoConfig.setSearchIds((String) values[10]);
- _require = (String) values[11];
- _provide = (String) values[12];
- _debugConsole = (Boolean) values[13];
- _dojoConfig.setDebugAtAllCosts((Boolean) values[14]);
- _expanded = (Boolean)values[15];
+ public Boolean getDebug() {
+ return _dojoConfig.getDebug();
}
- public Object saveState(FacesContext context)
- {
- Object values[] = new Object[16];
- values[0] = super.saveState(context);
- values[1] = _dojoConfig.getAllowQueryConfig();
- values[2] = _dojoConfig.getBaseScriptUri();
- values[3] = _dojoConfig.getBindEncoding();
- values[4] = _dojoConfig.getDebug();
- values[5] = _dojoConfig.getDebugContainerId();
- values[6] = _dojoConfig.getIgnoreClassNames();
- values[7] = _dojoConfig.getIoSendTransport();
- values[8] = _dojoConfig.getParseWidgets();
- values[9] = _dojoConfig.getPreventBackButtonFix();
- values[10] = _dojoConfig.getSearchIds();
- values[11] = _require;
- values[12] = _provide;
- values[13] = _debugConsole;
- values[14] = _dojoConfig.getDebugAtAllCosts();
- values[15] = _expanded;
- return values;
+ public Boolean getDebugAtAllCosts() {
+ return _dojoConfig.getDebugAtAllCosts();
}
- public Boolean getAllowQueryConfig()
- {
- return _dojoConfig.getAllowQueryConfig();
+ public Boolean getDebugConsole() {
+ return _debugConsole;
}
- public String getBaseScriptUri()
- {
- return _dojoConfig.getBaseScriptUri();
+ public String getDebugContainerId() {
+ return _dojoConfig.getDebugContainerId();
}
- public Boolean getBindEncoding()
- {
- return _dojoConfig.getBindEncoding();
+ public DojoConfig getDojoConfig() {
+ return _dojoConfig;
}
- public Boolean getDebug()
- {
- return _dojoConfig.getDebug();
+ public Boolean getExpanded() {
+ return _expanded;
}
- public String getDebugContainerId()
- {
- return _dojoConfig.getDebugContainerId();
+ public String getFamily() {
+ return COMPONENT_FAMILY;
}
- public Boolean getIgnoreClassNames()
- {
+ public Boolean getIgnoreClassNames() {
return _dojoConfig.getIgnoreClassNames();
}
- public Boolean getIoSendTransport()
- {
+ public Boolean getIoSendTransport() {
return _dojoConfig.getIoSendTransport();
}
- public Boolean getParseWidgets()
- {
+ public Boolean getParseWidgets() {
return _dojoConfig.getParseWidgets();
}
- public Boolean getPreventBackButtonFix()
- {
+ public Boolean getPreventBackButtonFix() {
return _dojoConfig.getPreventBackButtonFix();
}
- public String getSearchIds()
- {
+ public String getProvide() {
+ return _provide;
+ }
+
+ public String getRendererType() {
+ return DojoInitializerRenderer.RENDERER_TYPE;
+ }
+
+ public String getRequire() {
+ return _require;
+ }
+
+ public String getSearchIds() {
return _dojoConfig.getSearchIds();
}
- public void setAllowQueryConfig(Boolean allowQueryConfig)
- {
- if (allowQueryConfig != null)
- {
+ public Object getValue() {
+ return "DojoInitializers";
+ }
+
+ public boolean isDojoConfigParamSet() {
+ return dojoConfigParamSet;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+ _dojoConfig.setAllowQueryConfig((Boolean) values[1]);
+ _dojoConfig.setBaseScriptUri((String) values[2]);
+ _dojoConfig.setBindEncoding((Boolean) values[3]);
+ _dojoConfig.setDebug((Boolean) values[4]);
+ _dojoConfig.setDebugContainerId((String) values[5]);
+ _dojoConfig.setIgnoreClassNames((Boolean) values[6]);
+ _dojoConfig.setIoSendTransport((Boolean) values[7]);
+ _dojoConfig.setParseWidgets((Boolean) values[8]);
+ _dojoConfig.setPreventBackButtonFix((Boolean) values[9]);
+ _dojoConfig.setSearchIds((String) values[10]);
+ _require = (String) values[11];
+ _provide = (String) values[12];
+ _debugConsole = (Boolean) values[13];
+ _dojoConfig.setDebugAtAllCosts((Boolean) values[14]);
+ _expanded = (Boolean) values[15];
+ }
+
+ public Object saveState(FacesContext context) {
+ Object[] values = new Object[16];
+ values[0] = super.saveState(context);
+ values[1] = _dojoConfig.getAllowQueryConfig();
+ values[2] = _dojoConfig.getBaseScriptUri();
+ values[3] = _dojoConfig.getBindEncoding();
+ values[4] = _dojoConfig.getDebug();
+ values[5] = _dojoConfig.getDebugContainerId();
+ values[6] = _dojoConfig.getIgnoreClassNames();
+ values[7] = _dojoConfig.getIoSendTransport();
+ values[8] = _dojoConfig.getParseWidgets();
+ values[9] = _dojoConfig.getPreventBackButtonFix();
+ values[10] = _dojoConfig.getSearchIds();
+ values[11] = _require;
+ values[12] = _provide;
+ values[13] = _debugConsole;
+ values[14] = _dojoConfig.getDebugAtAllCosts();
+ values[15] = _expanded;
+
+ return values;
+ }
+
+ public void setAllowQueryConfig(Boolean allowQueryConfig) {
+
+ if (allowQueryConfig != null) {
dojoConfigParamSet = true;
DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setAllowQueryConfig(allowQueryConfig);
}
+
_dojoConfig.setAllowQueryConfig(allowQueryConfig);
-
+
}
- public void setBaseScriptUri(String baseScriptUri)
- {
- if (baseScriptUri != null)
- {
+ public void setBaseScriptUri(String baseScriptUri) {
+
+ if (baseScriptUri != null) {
dojoConfigParamSet = true;
DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setBaseScriptUri(baseScriptUri);
}
+
_dojoConfig.setBaseScriptUri(baseScriptUri);
}
- public void setBindEncoding(Boolean bindEncoding)
- {
- if (bindEncoding != null)
- {
+ public void setBindEncoding(Boolean bindEncoding) {
+
+ if (bindEncoding != null) {
dojoConfigParamSet = true;
DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setBindEncoding(bindEncoding);
}
@@ -192,150 +203,113 @@
_dojoConfig.setBindEncoding(bindEncoding);
}
- public void setDebug(Boolean debug)
- {
- if (debug != null)
- {
+ public void setDebug(Boolean debug) {
+
+ if (debug != null) {
dojoConfigParamSet = true;
DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setDebug(debug);
}
+
_dojoConfig.setDebug(debug);
-
+
}
- public void setDebugContainerId(String debugContainerId)
- {
- if (debugContainerId != null)
- {
+ public void setDebugAtAllCosts(Boolean debugAtAllCosts) {
+
+ if (debugAtAllCosts != null) {
+ dojoConfigParamSet = true;
+ DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setDebugAtAllCosts(debugAtAllCosts);
+ }
+
+ _dojoConfig.setDebugAtAllCosts(debugAtAllCosts);
+ }
+
+ public void setDebugConsole(Boolean debugConsole) {
+ this._debugConsole = debugConsole;
+ }
+
+ public void setDebugContainerId(String debugContainerId) {
+
+ if (debugContainerId != null) {
dojoConfigParamSet = true;
DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setDebugContainerId(debugContainerId);
}
+
_dojoConfig.setDebugContainerId(debugContainerId);
}
- public void setIgnoreClassNames(Boolean ignoreClassNames)
- {
- if (ignoreClassNames != null)
- {
+ public void setDojoConfigParamSet(boolean dojoConfigParamSet) {
+ this.dojoConfigParamSet = dojoConfigParamSet;
+ }
+
+ public void setExpanded(Boolean expanded) {
+
+ //we have a logical or over all expanded tags
+ if (expanded != null) {
+ dojoConfigParamSet = true;
+ DojoUtils.setExpanded(FacesContext.getCurrentInstance(), expanded);
+ }
+
+ _expanded = expanded;
+ }
+
+ public void setIgnoreClassNames(Boolean ignoreClassNames) {
+
+ if (ignoreClassNames != null) {
dojoConfigParamSet = true;
DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setIgnoreClassNames(ignoreClassNames);
}
+
_dojoConfig.setIgnoreClassNames(ignoreClassNames);
}
- public void setIoSendTransport(Boolean ioSendTransport)
- {
- if (ioSendTransport != null)
- {
+ public void setIoSendTransport(Boolean ioSendTransport) {
+
+ if (ioSendTransport != null) {
dojoConfigParamSet = true;
DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setIoSendTransport(ioSendTransport);
}
+
_dojoConfig.setIoSendTransport(ioSendTransport);
-
+
}
- public void setParseWidgets(Boolean parseWidgets)
- {
- if (parseWidgets != null)
- {
+ public void setParseWidgets(Boolean parseWidgets) {
+
+ if (parseWidgets != null) {
dojoConfigParamSet = true;
DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setParseWidgets(parseWidgets);
}
+
_dojoConfig.setParseWidgets(parseWidgets);
}
- public void setPreventBackButtonFix(Boolean preventBackButtonFix)
- {
- if (preventBackButtonFix != null)
- {
- dojoConfigParamSet = true;
- DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setPreventBackButtonFix(
- preventBackButtonFix);
- }
- _dojoConfig.setPreventBackButtonFix(preventBackButtonFix);
- }
+ public void setPreventBackButtonFix(Boolean preventBackButtonFix) {
- public void setSearchIds(String searchIds)
- {
- if (searchIds != null)
- {
+ if (preventBackButtonFix != null) {
dojoConfigParamSet = true;
- DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setSearchIds(searchIds);
+ DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setPreventBackButtonFix(preventBackButtonFix);
}
- _dojoConfig.setSearchIds(searchIds);
- }
-
- public DojoConfig getDojoConfig()
- {
- return _dojoConfig;
- }
- public String getRequire()
- {
- return _require;
- }
-
- public void setRequire(String required)
- {
- this._require = required;
- }
-
- public String getProvide()
- {
- return _provide;
+ _dojoConfig.setPreventBackButtonFix(preventBackButtonFix);
}
- public void setProvide(String provide)
- {
+ public void setProvide(String provide) {
this._provide = provide;
}
- public Boolean getDebugConsole()
- {
- return _debugConsole;
- }
-
- public void setDebugConsole(Boolean debugConsole)
- {
- this._debugConsole = debugConsole;
- }
-
- public boolean isDojoConfigParamSet()
- {
- return dojoConfigParamSet;
+ public void setRequire(String required) {
+ this._require = required;
}
- public void setDojoConfigParamSet(boolean dojoConfigParamSet)
- {
- this.dojoConfigParamSet = dojoConfigParamSet;
- }
+ public void setSearchIds(String searchIds) {
- public Boolean getDebugAtAllCosts() {
- return _dojoConfig.getDebugAtAllCosts();
- }
-
- public void setDebugAtAllCosts(Boolean debugAtAllCosts)
- {
- if (debugAtAllCosts != null)
- {
+ if (searchIds != null) {
dojoConfigParamSet = true;
- DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setDebugAtAllCosts(debugAtAllCosts);
+ DojoUtils.getDjConfigInstance(FacesContext.getCurrentInstance()).setSearchIds(searchIds);
}
- _dojoConfig.setDebugAtAllCosts(debugAtAllCosts);
- }
- public Boolean getExpanded() {
- return _expanded;
- }
-
- public void setExpanded(Boolean expanded) {
-
- //we have a logical or over all expanded tags
- if(expanded != null) {
- dojoConfigParamSet = true;
- DojoUtils.setExpanded(FacesContext.getCurrentInstance(), expanded);
- }
- _expanded = expanded;
+ _dojoConfig.setSearchIds(searchIds);
}
-
+
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerRenderer.java?rev=391791&r1=391790&r2=391791&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerRenderer.java Wed Apr 5 13:31:58 2006
@@ -16,65 +16,33 @@
package org.apache.myfaces.custom.dojo;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
+
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
/**
* Dojointializerrenderer
- *
+ *
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class DojoInitializerRenderer extends HtmlRenderer
-{
+public class DojoInitializerRenderer extends HtmlRenderer {
public static final String RENDERER_TYPE = "org.apache.myfaces.DojoInitializerRenderer";
- public void decode(FacesContext context, UIComponent component)
- {
+ public void decode(FacesContext context, UIComponent component) {
super.decode(context, component);
}
- /**
- * Encodes any stand-alone javascript functions that are needed. Uses either
- * the extension filter, or a user-supplied location for the javascript
- * files.
- *
- * @param context
- * FacesContext
- * @param component
- * UIComponent
- */
- private void encodeJavascript(FacesContext context, UIComponent component) throws IOException
- {
- String javascriptLocation = (String) component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
- DojoUtils.addMainInclude(context, component, javascriptLocation, DojoUtils.getDjConfigInstance(context));
- String require = (String) component.getAttributes().get("require");
- String provide = (String) component.getAttributes().get("provide");
-
- if (provide != null)
- DojoUtils.addProvide(context, component, provide);
-
- if (require != null)
- DojoUtils.addRequire(context, component, require);
-
- }
-
- public boolean getRendersChildren()
- {
- return false;
- }
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException
- {
- if ((context == null) || (component == null))
- {
+ if ((context == null) || (component == null)) {
throw new NullPointerException();
}
@@ -91,16 +59,43 @@
* Standard encode end
*
*/
- public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
- {
+ public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
super.encodeEnd(facesContext, component);
encodeJavascript(facesContext, component);
- if (((DojoInitializer) component).getDebugConsole() != null
- && ((DojoInitializer) component).getDebugConsole().booleanValue())
- {
+
+ if ((((DojoInitializer) component).getDebugConsole() != null) && ((DojoInitializer) component).getDebugConsole().booleanValue()) {
DojoUtils.addDebugConsole(facesContext, component);
}
+ }
+
+ public boolean getRendersChildren() {
+ return false;
+ }
+
+ /**
+ * Encodes any stand-alone javascript functions that are needed. Uses either
+ * the extension filter, or a user-supplied location for the javascript
+ * files.
+ *
+ * @param context
+ * FacesContext
+ * @param component
+ * UIComponent
+ */
+ private void encodeJavascript(FacesContext context, UIComponent component) throws IOException {
+ String javascriptLocation = (String) component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+ DojoUtils.addMainInclude(context, component, javascriptLocation, DojoUtils.getDjConfigInstance(context));
+
+ String require = (String) component.getAttributes().get("require");
+ String provide = (String) component.getAttributes().get("provide");
+
+ if (provide != null)
+ DojoUtils.addProvide(context, component, provide);
+
+ if (require != null)
+ DojoUtils.addRequire(context, component, require);
+
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerTag.java?rev=391791&r1=391790&r2=391791&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerTag.java Wed Apr 5 13:31:58 2006
@@ -16,165 +16,144 @@
package org.apache.myfaces.custom.dojo;
+import org.apache.myfaces.shared_tomahawk.taglib.html.HtmlOutputTextTagBase;
+
import javax.faces.component.UIComponent;
-import org.apache.myfaces.shared_tomahawk.taglib.html.HtmlOutputTextTagBase;
/**
* Tag for the dojo intializer code
- *
+ *
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class DojoInitializerTag extends HtmlOutputTextTagBase
-{
- String _ioSendTransport = null;
- String _debug = null;
- String _baseScriptUri = null;
+public class DojoInitializerTag extends HtmlOutputTextTagBase {
String _allowQueryConfig = null;
- String _debugContainerId = null;
- String _searchIds = null;
- String _parseWidgets = null;
+ String _baseScriptUri = null;
String _bindEncoding = null;
- String _ignoreClassNames = null;
- String _preventBackButtonFix = null;
- String _require = null;
- String _provide = null;
- String _debugConsole = null;
+ String _debug = null;
String _debugAtAllCosts = null;
+ String _debugConsole = null;
+ String _debugContainerId = null;
String _development = null;
String _expanded = null;
-
- public String getComponentType()
- {
+ String _ignoreClassNames = null;
+ String _ioSendTransport = null;
+ String _parseWidgets = null;
+ String _preventBackButtonFix = null;
+ String _provide = null;
+ String _require = null;
+ String _searchIds = null;
+
+ public String getComponentType() {
return DojoInitializer.COMPONENT_TYPE;
}
- public String getRendererType()
- {
+ public String getRendererType() {
return DojoInitializerRenderer.RENDERER_TYPE;
}
- public void release()
- {
+ public void release() {
super.release();
- _ioSendTransport = null;
- _debug = null;
- _baseScriptUri = null;
- _allowQueryConfig = null;
- _debugContainerId = null;
- _searchIds = null;
- _parseWidgets = null;
- _bindEncoding = null;
- _ignoreClassNames = null;
+ _ioSendTransport = null;
+ _debug = null;
+ _baseScriptUri = null;
+ _allowQueryConfig = null;
+ _debugContainerId = null;
+ _searchIds = null;
+ _parseWidgets = null;
+ _bindEncoding = null;
+ _ignoreClassNames = null;
_preventBackButtonFix = null;
- _require = null;
- _provide = null;
- _debugConsole = null;
- _debugAtAllCosts = null;
- _development = null;
- _expanded = null;
- }
-
- protected void setProperties(UIComponent component)
- {
- super.setProperties(component);
- super.setBooleanProperty(component, "ioSendTransport", _ioSendTransport);
- super.setBooleanProperty(component, "debug", _debug);
- super.setStringProperty(component, "baseScriptUri", _baseScriptUri);
- super.setBooleanProperty(component, "allowQueryConfig", _allowQueryConfig);
- super.setStringProperty(component, "debugContainerId", _debugContainerId);
- super.setStringProperty(component, "searchIds", _searchIds);
- super.setBooleanProperty(component, "parseWidgets", _parseWidgets);
- super.setBooleanProperty(component, "bindEncoding", _bindEncoding);
-
- super.setBooleanProperty(component, "ignoreClassNames", _ignoreClassNames);
- super.setBooleanProperty(component, "preventBackButtonFix", _preventBackButtonFix);
-
- super.setStringProperty(component, "require", _require);
- super.setStringProperty(component, "provide", _provide);
- super.setBooleanProperty(component, "debugConsole", _debugConsole);
- super.setBooleanProperty(component, "debugAtAllCosts", _debugAtAllCosts);
-
- super.setBooleanProperty(component,"development", _development);
-
- super.setBooleanProperty(component, "expanded", _expanded);
+ _require = null;
+ _provide = null;
+ _debugConsole = null;
+ _debugAtAllCosts = null;
+ _development = null;
+ _expanded = null;
}
- public void setAllowQueryConfig(String allowQueryConfig)
- {
+ public void setAllowQueryConfig(String allowQueryConfig) {
this._allowQueryConfig = allowQueryConfig;
}
- public void setBaseScriptUri(String baseScriptUri)
- {
+ public void setBaseScriptUri(String baseScriptUri) {
this._baseScriptUri = baseScriptUri;
}
- public void setBindEncoding(String bindEncoding)
- {
+ public void setBindEncoding(String bindEncoding) {
this._bindEncoding = bindEncoding;
}
- public void setDebug(String debug)
- {
+ public void setDebug(String debug) {
this._debug = debug;
}
- public void setDebugContainerId(String debugContainerId)
- {
+ public void setDebugAtAllCosts(String debugAtAllCosts) {
+ this._debugAtAllCosts = debugAtAllCosts;
+ }
+
+ public void setDebugConsole(String debugConsole) {
+ this._debugConsole = debugConsole;
+ }
+
+ public void setDebugContainerId(String debugContainerId) {
this._debugContainerId = debugContainerId;
}
- public void setIgnoreClassNames(String ignoreClassNames)
- {
- this._ignoreClassNames = ignoreClassNames;
+ public void setDevelopment(String development) {
+ this._development = development;
}
- public void setIoSendTransport(String ioSendTransport)
- {
- this._ioSendTransport = ioSendTransport;
+ public void setExpanded(String expanded) {
+ this._expanded = expanded;
}
- public void setParseWidgets(String parseWidgets)
- {
- this._parseWidgets = parseWidgets;
+ public void setIgnoreClassNames(String ignoreClassNames) {
+ this._ignoreClassNames = ignoreClassNames;
}
- public void setPreventBackButtonFix(String preventBackButtonFix)
- {
- this._preventBackButtonFix = preventBackButtonFix;
+ public void setIoSendTransport(String ioSendTransport) {
+ this._ioSendTransport = ioSendTransport;
}
- public void setSearchIds(String searchIds)
- {
- this._searchIds = searchIds;
+ public void setParseWidgets(String parseWidgets) {
+ this._parseWidgets = parseWidgets;
}
- public void setRequire(String require)
- {
- this._require = require;
+ public void setPreventBackButtonFix(String preventBackButtonFix) {
+ this._preventBackButtonFix = preventBackButtonFix;
}
public void setProvide(String provide) {
this._provide = provide;
}
- public void setDebugConsole(String debugConsole)
- {
- this._debugConsole = debugConsole;
+ public void setRequire(String require) {
+ this._require = require;
}
- public void setDebugAtAllCosts(String debugAtAllCosts)
- {
- this._debugAtAllCosts = debugAtAllCosts;
+ public void setSearchIds(String searchIds) {
+ this._searchIds = searchIds;
}
- public void setDevelopment(String development) {
- this._development = development;
- }
-
- public void setExpanded(String expanded) {
- this._expanded = expanded;
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+ super.setBooleanProperty(component, "ioSendTransport", _ioSendTransport);
+ super.setBooleanProperty(component, "debug", _debug);
+ super.setStringProperty(component, "baseScriptUri", _baseScriptUri);
+ super.setBooleanProperty(component, "allowQueryConfig", _allowQueryConfig);
+ super.setStringProperty(component, "debugContainerId", _debugContainerId);
+ super.setStringProperty(component, "searchIds", _searchIds);
+ super.setBooleanProperty(component, "parseWidgets", _parseWidgets);
+ super.setBooleanProperty(component, "bindEncoding", _bindEncoding);
+ super.setBooleanProperty(component, "ignoreClassNames", _ignoreClassNames);
+ super.setBooleanProperty(component, "preventBackButtonFix", _preventBackButtonFix);
+ super.setStringProperty(component, "require", _require);
+ super.setStringProperty(component, "provide", _provide);
+ super.setBooleanProperty(component, "debugConsole", _debugConsole);
+ super.setBooleanProperty(component, "debugAtAllCosts", _debugAtAllCosts);
+ super.setBooleanProperty(component, "development", _development);
+ super.setBooleanProperty(component, "expanded", _expanded);
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoResourceLoader.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoResourceLoader.java?rev=391791&r1=391790&r2=391791&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoResourceLoader.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoResourceLoader.java Wed Apr 5 13:31:58 2006
@@ -19,11 +19,10 @@
/**
* Resource loader for the dojo lib javascripts
- *
+ *
* @author werpu (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public interface DojoResourceLoader
-{
+public interface DojoResourceLoader {
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java?rev=391791&r1=391790&r2=391791&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java Wed Apr 5 13:31:58 2006
@@ -16,23 +16,27 @@
package org.apache.myfaces.custom.dojo;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+
import java.io.IOException;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+
import java.util.Set;
import java.util.TreeSet;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+
import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
-import org.apache.myfaces.renderkit.html.util.AddResource;
-import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
-import org.apache.myfaces.renderkit.html.util.MyFacesResourceHandler;
/**
* Utils class for the dojo infrastructure
@@ -45,119 +49,67 @@
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public final class DojoUtils
-{
- private static final String INCL_TYPE_REQ_KEY = "DOJO_DEVELOPMENT_INCLUDE";
- private static final Log log = LogFactory.getLog(DojoUtils.class);
- private static final String DOJO_PROVIDE = "dojo.provide:";
- private static final String DOJO_REQUIRE = "dojo.require:";
- private static final String DJCONFIG_INITKEY = "/*djconfig init*/";
-
- private DojoUtils()
- {
- //nope
- }
-
+public final class DojoUtils {
+ private static final String INCL_TYPE_REQ_KEY = "DOJO_DEVELOPMENT_INCLUDE";
+ private static final Log log = LogFactory.getLog(DojoUtils.class);
+ private static final String DOJO_PROVIDE = "dojo.provide:";
+ private static final String DOJO_REQUIRE = "dojo.require:";
+ private static final String DJCONFIG_INITKEY = "/*djconfig init*/";
private static final String BODY_SCRIPT_INFOS_ATTRIBUTE_NAME = "bodyScriptInfos";
private static final String DOJO_FILE_UNCOMPRESSED = "dojo.js.uncompressed.js";
private static final String DOJO_FILE = "dojo.js";
private static final String DJCONFIG_REQ_KEY = "MYFACES_DJCONFIG";
+ private DojoUtils() {
+ //nope
+ }
+
/**
- * Request singleton getter method for the djConfig object
+ * adds a debug console to the output
+ * this is for helping to debug the dojo system
+ * a debug:true is required for this to work properly
+ * it will not be set by this method (due to the avoidance
+ * of unwanted automatisms causing sideefects)
*
- * @param context
+ * @param facesContext
+ * @param component
* @return
*/
- public static DojoConfig getDjConfigInstance(FacesContext context)
- {
- //we wont have a need for a synchronized here, since
- //we are in a single request cycle anyway
- //but take care if you use the djconfig in multiple threads!
- DojoConfig djConfig = (DojoConfig) ((HttpServletRequest) context.getExternalContext().getRequest())
- .getAttribute(DJCONFIG_REQ_KEY);
- if (djConfig == null)
- {
- djConfig = new DojoConfig();
- ((HttpServletRequest) context.getExternalContext().getRequest()).setAttribute(DJCONFIG_REQ_KEY, djConfig);
- }
- return djConfig;
- }
+ public static void addDebugConsole(FacesContext facesContext, UIComponent component) throws IOException {
- /**
- * helper to merge in an external dojo config instance
- * the merge algorithm is that an existing entry is overwritten
- * if a new config entry is set
- * make sure that this is not called too often
- * due to the fact that we do heavy reflection in here
- * @param context
- * @param config
- */
- public static void mergeExternalDjConfig(FacesContext context, DojoConfig config)
- {
- //we now do the same as beanutils, but for dependency reasons we code it
- DojoConfig configSingleton = getDjConfigInstance(context);
- Class dcConfigClass = DojoConfig.class;
- Method[] djConfigFieldArr = dcConfigClass.getMethods();
- for (int cnt = 0; cnt < djConfigFieldArr.length; cnt++)
- {
+ /*check whether we have a debugging flag already set*/
+ if (isInlineScriptSet(facesContext, "/*DOJO DEBUGCONSOLE ON*/"))
+ return;
- try
- {
- Method configPropertyField = djConfigFieldArr[cnt];
- String methodCore = null;
- if (!configPropertyField.getName().startsWith("getClass")
- && configPropertyField.getName().startsWith("get")
- || configPropertyField.getName().startsWith("is"))
- methodCore = (configPropertyField.getName().startsWith("get")) ? configPropertyField.getName()
- .substring(3) : configPropertyField.getName().substring(2);
+ AddResource addResource = AddResourceFactory.getInstance(facesContext);
+ addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, "/*DOJO DEBUGCONSOLE ON*/");
- if (methodCore != null)
- {
- Object val = configPropertyField.invoke(config, null);
- if (val != null)
- {
- Class[] setterParams = new Class[1];
- setterParams[0] = val.getClass();
- Method setMethod = dcConfigClass.getMethod("set" + methodCore, setterParams);
- if (setMethod != null)
- {
- Object[] setterArgs = new Object[1];
- setterArgs[0] = val;
- setMethod.invoke(configSingleton, setterArgs);
- }
- }
- }
- }
- catch (IllegalArgumentException e)
- {
- log.error(e);
- }
- catch (SecurityException e)
- {
- log.error(e);
- }
- catch (IllegalAccessException e)
- {
- log.error(e);
- }
- catch (InvocationTargetException e)
- {
- log.error(e);
- }
- catch (NoSuchMethodException e)
- {
- log.error(e);
- }
- }
+ ResponseWriter writer = facesContext.getResponseWriter();
+ //we for now have to break html until the dynamic creation
+ //isses are resolved, so hold on for this messy code now
+ //Since this is for debugging purposes only, we can live with it
+
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute(HTML.ID_ATTR, "myfaces_Dojo_Debugger", null);
+ writer.writeAttribute("dojoType", "DebugConsole", null);
+ writer.writeAttribute("title", "MyFaces Dojo Debug console", null);
+ writer.writeAttribute("iconSrc", "images/flatScreen.gif", null);
+ writer.writeAttribute("constrainToContainer", "1", null);
+ writer.writeAttribute(HTML.STYLE_ATTR, "width: 400px; height: 500px; left: 200px;", null);
+ writer.writeAttribute("hasShadow", "true", null);
+ writer.writeAttribute("resizable", "true", null);
+ writer.writeAttribute("displayCloseAction", "true", null);
+ writer.writeAttribute("layoutAlign", "client", null);
+
+ writer.endElement(HTML.DIV_ELEM);
}
- public static void addMainInclude(FacesContext facesContext, UIComponent component, String javascriptLocation,
- DojoConfig config) throws IOException
- {
+ public static void addMainInclude(FacesContext facesContext, UIComponent component, String javascriptLocation, DojoConfig config)
+ throws IOException {
AddResource addResource = AddResourceFactory.getInstance(facesContext);
+
/*
* var djConfig = {
isDebug: false
@@ -165,96 +117,31 @@
TODO add a saner handling of collecting all djconfig data
and then merging it
*/
- if (!isInlineScriptSet(facesContext, DJCONFIG_INITKEY))
- {
+ if (!isInlineScriptSet(facesContext, DJCONFIG_INITKEY)) {
addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, DJCONFIG_INITKEY);
addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, config.toString());
- String dojofile = (getExpanded(facesContext) != null && getExpanded(facesContext).booleanValue()) ? DOJO_FILE_UNCOMPRESSED
- : DOJO_FILE;
- if (javascriptLocation != null)
- {
- addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, javascriptLocation
- + dojofile);
- }
- else
- {
- /*ResponseWriter writer = facesContext.getResponseWriter();
- writer.startElement(HTML.SCRIPT_ELEM,component);
-
- MyFacesResourceHandler handler = new MyFacesResourceHandler(DojoResourceLoader.class, dojofile);
- String uri = handler.getResourceUri(facesContext);
- uri = uri.replaceAll("dojo\\.js\\;jsessionid(.)*\\\"","dojo.js");
- writer.writeAttribute(HTML.SRC_ATTR, uri, null);
-
- writer.endElement(HTML.SCRIPT_ELEM);
- addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, DojoResourceLoader.class, dojofile);
- */
-
- addResource.addJavaScriptAtPositionPlain(facesContext, AddResource.HEADER_BEGIN,DojoResourceLoader.class,
- dojofile);
- }
- }
-
- }
-
- /**
- * adds a dojo require include to our mix
- * of stuff used
- *
- * @param facesContext
- * @param required
- */
- public static void addRequire(FacesContext facesContext, UIComponent component, String required) throws IOException
- {
- if (isInlineScriptSet(facesContext, DOJO_REQUIRE + required))
- return;
-
- String requireAsScript = createDojoRequireString(required);
- ResponseWriter writer = facesContext.getResponseWriter();
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
- writer.write(requireAsScript);
- writer.endElement(HTML.SCRIPT_ELEM);
- }
+ String dojofile = ((getExpanded(facesContext) != null) && getExpanded(facesContext).booleanValue()) ? DOJO_FILE_UNCOMPRESSED : DOJO_FILE;
- /**
- * helper method for the proper dojo require script creation
- * @param required the creation package for the require functionality
- * @return dojoRequire String
- */
- public static String createDojoRequireString(String required)
- {
- StringBuffer requiredBuilder = new StringBuffer(32);
- requiredBuilder.append("dojo.require('");
- requiredBuilder.append(required);
- requiredBuilder.append("');");
- return requiredBuilder.toString();
- }
+ if (javascriptLocation != null) {
+ addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, javascriptLocation + dojofile);
+ } else {
+ /*ResponseWriter writer = facesContext.getResponseWriter();
+ writer.startElement(HTML.SCRIPT_ELEM,component);
+
+ MyFacesResourceHandler handler = new MyFacesResourceHandler(DojoResourceLoader.class, dojofile);
+ String uri = handler.getResourceUri(facesContext);
+ uri = uri.replaceAll("dojo\\.js\\;jsessionid(.)*\\\"","dojo.js");
+ writer.writeAttribute(HTML.SRC_ATTR, uri, null);
+
+ writer.endElement(HTML.SCRIPT_ELEM);
+ addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, DojoResourceLoader.class, dojofile);
+ */
- private static Set getBodyScriptInfos(HttpServletRequest request)
- {
- Set set = (Set) request.getAttribute(BODY_SCRIPT_INFOS_ATTRIBUTE_NAME);
- if (set == null)
- {
- set = new TreeSet();
- request.setAttribute(BODY_SCRIPT_INFOS_ATTRIBUTE_NAME, set);
+ addResource.addJavaScriptAtPositionPlain(facesContext, AddResource.HEADER_BEGIN, DojoResourceLoader.class, dojofile);
+ }
}
- return set;
- }
-
- public static boolean isInlineScriptSet(FacesContext context, String inlineScript)
- {
- //TODO move this non neutral code into the resource handler
- HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
- Set set = getBodyScriptInfos(request);
- if (!set.contains(inlineScript))
- {
- set.add(inlineScript);
- return false;
- }
- return true;
}
/**
@@ -264,19 +151,19 @@
* @param provided the package with the class provided by this implementation
* @see <a href="http://dojotoolkit.org/docs/fast_widget_authoring.html">Dojo-Widget-Authoring</a> for an example on this
*/
- public static void addProvide(FacesContext context, String provided)
- {
+ public static void addProvide(FacesContext context, String provided) {
+
if (isInlineScriptSet(context, DOJO_PROVIDE + provided))
return;
- AddResource addResource = AddResourceFactory.getInstance(context);
- String providedBuilder = createDojoProvideScript(provided);
+ AddResource addResource = AddResourceFactory.getInstance(context);
+ String providedBuilder = createDojoProvideScript(provided);
addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, providedBuilder);
}
- public static void addProvide(FacesContext facesContext, UIComponent component, String provided) throws IOException
- {
+ public static void addProvide(FacesContext facesContext, UIComponent component, String provided) throws IOException {
+
if (isInlineScriptSet(facesContext, DOJO_PROVIDE + provided))
return;
@@ -291,94 +178,174 @@
}
/**
+ * adds a dojo require include to our mix
+ * of stuff used
+ *
+ * @param facesContext
+ * @param required
+ */
+ public static void addRequire(FacesContext facesContext, UIComponent component, String required) throws IOException {
+
+ if (isInlineScriptSet(facesContext, DOJO_REQUIRE + required))
+ return;
+
+ String requireAsScript = createDojoRequireString(required);
+ ResponseWriter writer = facesContext.getResponseWriter();
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+ writer.write(requireAsScript);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ }
+
+ /**
+ * creates a debug statement for the debug console
+ * @param stmnt the debug message displayed by the debug console
+ * @return javaScriptcode String
+ */
+ public static String createDebugStatement(String stmnt) {
+ return "dojo.debug(\"" + stmnt + "\");\n";
+ }
+
+ /**
+ * creates a debug statement and a corresponding value for the debug console
+ * @param stmnt the debug message displayed and given value by the debug console
+ * @return javaScriptcode String
+ */
+ public static String createDebugStatement(String stmnt, String value) {
+ return "dojo.debug(\"" + stmnt + ":\");dojo.debug(" + value + ");\n";
+ }
+
+ /**
* helper method which does the proper dojo provide script creation
* @param provided the provided class name
* @return dojoProvide String
*/
- public static String createDojoProvideScript(String provided)
- {
+ public static String createDojoProvideScript(String provided) {
StringBuffer providedBuilder = new StringBuffer(32);
providedBuilder.append("dojo.provide('");
- providedBuilder.append(provided);
+ providedBuilder.append(provided.trim());
providedBuilder.append("');");
+
return providedBuilder.toString();
}
/**
- * adds a debug console to the output
- * this is for helping to debug the dojo system
- * a debug:true is required for this to work properly
- * it will not be set by this method (due to the avoidance
- * of unwanted automatisms causing sideefects)
+ * helper method for the proper dojo require script creation
+ * @param required the creation package for the require functionality
+ * @return dojoRequire String
+ */
+ public static String createDojoRequireString(String required) {
+ StringBuffer requiredBuilder = new StringBuffer(32);
+ requiredBuilder.append("dojo.require('");
+ requiredBuilder.append(required.trim());
+ requiredBuilder.append("');");
+
+ return requiredBuilder.toString();
+ }
+
+ /**
+ * Request singleton getter method for the djConfig object
*
- * @param facesContext
- * @param component
+ * @param context
* @return
*/
- public static void addDebugConsole(FacesContext facesContext, UIComponent component) throws IOException
- {
- /*check whether we have a debugging flag already set*/
- if (isInlineScriptSet(facesContext, "/*DOJO DEBUGCONSOLE ON*/"))
- return;
- AddResource addResource = AddResourceFactory.getInstance(facesContext);
- addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, "/*DOJO DEBUGCONSOLE ON*/");
-
- ResponseWriter writer = facesContext.getResponseWriter();
- //we for now have to break html until the dynamic creation
- //isses are resolved, so hold on for this messy code now
- //Since this is for debugging purposes only, we can live with it
+ public static DojoConfig getDjConfigInstance(FacesContext context) {
- writer.startElement(HTML.DIV_ELEM, component);
- writer.writeAttribute(HTML.ID_ATTR, "myfaces_Dojo_Debugger", null);
- writer.writeAttribute("dojoType", "DebugConsole", null);
- writer.writeAttribute("title", "MyFaces Dojo Debug console", null);
- writer.writeAttribute("iconSrc", "images/flatScreen.gif", null);
- writer.writeAttribute("constrainToContainer", "1", null);
- writer.writeAttribute(HTML.STYLE_ATTR, "width: 400px; height: 500px; left: 200px;", null);
- writer.writeAttribute("hasShadow", "true", null);
- writer.writeAttribute("resizable", "true", null);
- writer.writeAttribute("displayCloseAction", "true", null);
- writer.writeAttribute("layoutAlign", "client", null);
+ //we wont have a need for a synchronized here, since
+ //we are in a single request cycle anyway
+ //but take care if you use the djconfig in multiple threads!
+ DojoConfig djConfig = (DojoConfig) ((HttpServletRequest) context.getExternalContext().getRequest()).getAttribute(DJCONFIG_REQ_KEY);
- writer.endElement(HTML.DIV_ELEM);
+ if (djConfig == null) {
+ djConfig = new DojoConfig();
+ ((HttpServletRequest) context.getExternalContext().getRequest()).setAttribute(DJCONFIG_REQ_KEY, djConfig);
+ }
+ return djConfig;
}
/**
- * creates a debug statement for the debug console
- * @param stmnt the debug message displayed by the debug console
- * @return javaScriptcode String
+ * getter for the expanded flat
+ * @param facesContext
+ * @return
*/
- public static String createDebugStatement(String stmnt)
- {
- return "dojo.debug(\"" + stmnt + "\");\n";
+ public static Boolean getExpanded(FacesContext facesContext) {
+ HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
+ Boolean devStatus = (Boolean) request.getAttribute(INCL_TYPE_REQ_KEY);
+
+ return devStatus;
}
- /**
- * creates a debug statement and a corresponding value for the debug console
- * @param stmnt the debug message displayed and given value by the debug console
- * @return javaScriptcode String
- */
- public static String createDebugStatement(String stmnt, String value)
- {
- return "dojo.debug(\"" + stmnt + ":\");dojo.debug(" + value + ");\n";
+ public static boolean isInlineScriptSet(FacesContext context, String inlineScript) {
+
+ //TODO move this non neutral code into the resource handler
+ HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
+ Set set = getBodyScriptInfos(request);
+
+ if (!set.contains(inlineScript)) {
+ set.add(inlineScript);
+
+ return false;
+ }
+
+ return true;
}
/**
- * helper to write out debug statements
- * this is only a convenience method to reduce the
- * code bloat
- *
- * @param writer
- * @param stmnt
- * @return
- * @throws IOException
+ * helper to merge in an external dojo config instance
+ * the merge algorithm is that an existing entry is overwritten
+ * if a new config entry is set
+ * make sure that this is not called too often
+ * due to the fact that we do heavy reflection in here
+ * @param context
+ * @param config
*/
- public static void writeDebugStatement(ResponseWriter writer, String stmnt) throws IOException
- {
- stmnt = createDebugStatement(stmnt);
- writer.write(stmnt);
+ public static void mergeExternalDjConfig(FacesContext context, DojoConfig config) {
+
+ //we now do the same as beanutils, but for dependency reasons we code it
+ DojoConfig configSingleton = getDjConfigInstance(context);
+ Class dcConfigClass = DojoConfig.class;
+ Method[] djConfigFieldArr = dcConfigClass.getMethods();
+
+ for (int cnt = 0; cnt < djConfigFieldArr.length; cnt++) {
+
+ try {
+ Method configPropertyField = djConfigFieldArr[cnt];
+ String methodCore = null;
+
+ if ((!configPropertyField.getName().startsWith("getClass") && configPropertyField.getName().startsWith("get")) || configPropertyField.getName().startsWith("is"))
+ methodCore = (configPropertyField.getName().startsWith("get")) ? configPropertyField.getName().substring(3) : configPropertyField.getName().substring(2);
+
+ if (methodCore != null) {
+ Object val = configPropertyField.invoke(config, null);
+
+ if (val != null) {
+ Class[] setterParams = new Class[1];
+ setterParams[0] = val.getClass();
+
+ Method setMethod = dcConfigClass.getMethod("set" + methodCore, setterParams);
+
+ if (setMethod != null) {
+ Object[] setterArgs = new Object[1];
+ setterArgs[0] = val;
+ setMethod.invoke(configSingleton, setterArgs);
+ }
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ log.error(e);
+ } catch (SecurityException e) {
+ log.error(e);
+ } catch (IllegalAccessException e) {
+ log.error(e);
+ } catch (InvocationTargetException e) {
+ log.error(e);
+ } catch (NoSuchMethodException e) {
+ log.error(e);
+ }
+ }
+
}
/**
@@ -390,22 +357,35 @@
* @param expanded if set to true the expanded version of the dojo scripts are loaded
* otherwise the non expanded ones are loaded
*/
- public static void setExpanded(FacesContext facesContext, Boolean expanded)
- {
+ public static void setExpanded(FacesContext facesContext, Boolean expanded) {
HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
request.setAttribute(INCL_TYPE_REQ_KEY, expanded);
}
/**
- * getter for the expanded flat
- * @param facesContext
+ * helper to write out debug statements
+ * this is only a convenience method to reduce the
+ * code bloat
+ *
+ * @param writer
+ * @param stmnt
* @return
+ * @throws IOException
*/
- public static Boolean getExpanded(FacesContext facesContext)
- {
- HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
- Boolean devStatus = (Boolean) request.getAttribute(INCL_TYPE_REQ_KEY);
- return devStatus;
+ public static void writeDebugStatement(ResponseWriter writer, String stmnt) throws IOException {
+ stmnt = createDebugStatement(stmnt);
+ writer.write(stmnt);
+ }
+
+ private static Set getBodyScriptInfos(HttpServletRequest request) {
+ Set set = (Set) request.getAttribute(BODY_SCRIPT_INFOS_ATTRIBUTE_NAME);
+
+ if (set == null) {
+ set = new TreeSet();
+ request.setAttribute(BODY_SCRIPT_INFOS_ATTRIBUTE_NAME, set);
+ }
+
+ return set;
}
}