diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/AjaxEventInterceptorRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/AjaxEventInterceptorRenderer.java index 7548ccc1..acd131eb 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/AjaxEventInterceptorRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/AjaxEventInterceptorRenderer.java @@ -33,7 +33,7 @@ import org.springframework.util.StringUtils; * @author Jeremy Grelle * */ -public class AjaxEventInterceptorRenderer extends DojoDecorationRenderer { +public class AjaxEventInterceptorRenderer extends DojoElementDecorationRenderer { public void encodeEnd(FacesContext context, UIComponent component) throws IOException { String event = (String) component.getAttributes().get("event"); @@ -52,13 +52,14 @@ public class AjaxEventInterceptorRenderer extends DojoDecorationRenderer { } String childId = getElementId(context, component); StringBuffer script = new StringBuffer(); + script.append("dojo.addOnLoad(function(){"); script.append("Spring.addDecoration(new Spring.AjaxEventDecoration({"); script.append("event:'" + event + "'"); script.append(", elementId: '" + childId + "'"); script.append(", sourceId: '" + component.getClientId(context) + "'"); script.append(", formId : '" + RendererUtils.getFormId(context, component) + "'"); script.append(", params: {processIds : '" + processIds + "'"); - script.append(", ajaxSource : '" + component.getClientId(context) + "'} }));"); + script.append(", ajaxSource : '" + component.getClientId(context) + "'} }));});"); writer.writeText(script.toString(), null); @@ -68,7 +69,7 @@ public class AjaxEventInterceptorRenderer extends DojoDecorationRenderer { private String getElementId(FacesContext context, UIComponent component) { if (component.getChildCount() > 0) { UIComponent child = (UIComponent) component.getChildren().get(0); - if (!(child instanceof DojoDecoration)) { + if (!(child instanceof SpringJavascriptElementDecoration)) { return child.getClientId(context); } else { return getElementId(context, child); diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/BaseDojoComponentRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/BaseDojoComponentRenderer.java index 7706d3ac..c6b29a9c 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/BaseDojoComponentRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/BaseDojoComponentRenderer.java @@ -33,23 +33,20 @@ import org.springframework.faces.webflow.JsfUtils; */ public abstract class BaseDojoComponentRenderer extends BaseSpringJavascriptComponentRenderer { - private String dojoJsResourceUri = "/dojo/dojo.js"; - - private String dijitThemePath = "/dijit/themes/"; - - private String dijitTheme = "tundra"; - - private String springDojoJsResourceUri = "/spring/Spring-Dojo.js"; - public void encodeBegin(FacesContext context, UIComponent component) throws IOException { super.encodeBegin(context, component); if (!JsfUtils.isAsynchronousFlowRequest()) { - ResourceHelper.renderStyleLink(context, dijitThemePath + dijitTheme + "/" + dijitTheme + ".css"); - ResourceHelper.renderScriptLink(context, dojoJsResourceUri); + if (!context.getViewRoot().getAttributes().containsKey(DojoConstants.CUSTOM_THEME_PATH_SET) + && !context.getViewRoot().getAttributes().containsKey(DojoConstants.CUSTOM_THEME_SET)) { + ResourceHelper.renderStyleLink(context, DojoConstants.DIJIT_THEME_PATH + + DojoConstants.DEFAULT_DIJIT_THEME + "/" + DojoConstants.DEFAULT_DIJIT_THEME + ".css"); + } - ResourceHelper.renderScriptLink(context, springDojoJsResourceUri); + ResourceHelper.renderScriptLink(context, DojoConstants.DOJO_JS_RESOURCE_URI); + + ResourceHelper.renderScriptLink(context, DojoConstants.SPRING_DOJO_JS_RESOURCE_URI); } } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientCurrencyValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientCurrencyValidator.java index 36d6f8b6..9268fcef 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientCurrencyValidator.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientCurrencyValidator.java @@ -25,7 +25,7 @@ import javax.faces.el.ValueBinding; * @author Jeremy Grelle * */ -public class DojoClientCurrencyValidator extends DojoDecoration { +public class DojoClientCurrencyValidator extends DojoWidget { private static final String DOJO_COMPONENT_TYPE = "dijit.form.CurrencyTextBox"; @@ -34,9 +34,9 @@ public class DojoClientCurrencyValidator extends DojoDecoration { private static final String[] DOJO_ATTRS; static { - DOJO_ATTRS = new String[DojoDecoration.DOJO_ATTRS.length + DOJO_ATTRS_INTERNAL.length]; - System.arraycopy(DojoDecoration.DOJO_ATTRS, 0, DOJO_ATTRS, 0, DojoDecoration.DOJO_ATTRS.length); - System.arraycopy(DOJO_ATTRS_INTERNAL, 0, DOJO_ATTRS, DojoDecoration.DOJO_ATTRS.length, DOJO_ATTRS_INTERNAL.length); + DOJO_ATTRS = new String[DojoWidget.DOJO_ATTRS.length + DOJO_ATTRS_INTERNAL.length]; + System.arraycopy(DojoWidget.DOJO_ATTRS, 0, DOJO_ATTRS, 0, DojoWidget.DOJO_ATTRS.length); + System.arraycopy(DOJO_ATTRS_INTERNAL, 0, DOJO_ATTRS, DojoWidget.DOJO_ATTRS.length, DOJO_ATTRS_INTERNAL.length); } private String currency; @@ -57,7 +57,7 @@ public class DojoClientCurrencyValidator extends DojoDecoration { return DOJO_ATTRS; } - public String getDojoComponentType() { + public String getWidgetType() { return DOJO_COMPONENT_TYPE; } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java index 9ebad722..59d32fdd 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java @@ -28,7 +28,7 @@ import org.springframework.util.Assert; * @author Jeremy Grelle * */ -public class DojoClientDateValidator extends DojoDecoration { +public class DojoClientDateValidator extends DojoWidget { private static final String DOJO_COMPONENT_TYPE = "dijit.form.DateTextBox"; @@ -39,9 +39,9 @@ public class DojoClientDateValidator extends DojoDecoration { private String datePattern = null; static { - DOJO_ATTRS = new String[DojoDecoration.DOJO_ATTRS.length + DOJO_ATTRS_INTERNAL.length]; - System.arraycopy(DojoDecoration.DOJO_ATTRS, 0, DOJO_ATTRS, 0, DojoDecoration.DOJO_ATTRS.length); - System.arraycopy(DOJO_ATTRS_INTERNAL, 0, DOJO_ATTRS, DojoDecoration.DOJO_ATTRS.length, + DOJO_ATTRS = new String[DojoWidget.DOJO_ATTRS.length + DOJO_ATTRS_INTERNAL.length]; + System.arraycopy(DojoWidget.DOJO_ATTRS, 0, DOJO_ATTRS, 0, DojoWidget.DOJO_ATTRS.length); + System.arraycopy(DOJO_ATTRS_INTERNAL, 0, DOJO_ATTRS, DojoWidget.DOJO_ATTRS.length, DOJO_ATTRS_INTERNAL.length); } @@ -63,7 +63,7 @@ public class DojoClientDateValidator extends DojoDecoration { return DOJO_ATTRS; } - public String getDojoComponentType() { + public String getWidgetType() { return DOJO_COMPONENT_TYPE; } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientNumberValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientNumberValidator.java index 68e1700d..361db7db 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientNumberValidator.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientNumberValidator.java @@ -22,15 +22,15 @@ package org.springframework.faces.ui; * @author Jeremy Grelle * */ -public class DojoClientNumberValidator extends DojoDecoration { +public class DojoClientNumberValidator extends DojoWidget { private static final String DOJO_COMPONENT_TYPE = "dijit.form.NumberTextBox"; protected String[] getDojoAttributes() { - return DojoDecoration.DOJO_ATTRS; + return DojoWidget.DOJO_ATTRS; } - public String getDojoComponentType() { + public String getWidgetType() { return DOJO_COMPONENT_TYPE; } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientTextValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientTextValidator.java index 1c2f1532..a1da88c3 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientTextValidator.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientTextValidator.java @@ -22,15 +22,15 @@ package org.springframework.faces.ui; * @author Jeremy Grelle * */ -public class DojoClientTextValidator extends DojoDecoration { +public class DojoClientTextValidator extends DojoWidget { private static final String DOJO_COMPONENT_TYPE = "dijit.form.ValidationTextBox"; protected String[] getDojoAttributes() { - return DojoDecoration.DOJO_ATTRS; + return DojoWidget.DOJO_ATTRS; } - public String getDojoComponentType() { + public String getWidgetType() { return DOJO_COMPONENT_TYPE; } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoConstants.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoConstants.java new file mode 100644 index 00000000..002d0b4a --- /dev/null +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoConstants.java @@ -0,0 +1,12 @@ +package org.springframework.faces.ui; + +class DojoConstants { + + static final String DIJIT_THEME_PATH = "/dijit/themes/"; + static final String DEFAULT_DIJIT_THEME = "tundra"; + static final String DOJO_JS_RESOURCE_URI = "/dojo/dojo.js"; + static final String SPRING_DOJO_JS_RESOURCE_URI = "/spring/Spring-Dojo.js"; + static final String CUSTOM_THEME_PATH_SET = "dojoCustomThemePathSet"; + static final String CUSTOM_THEME_SET = "dojoCustomThemeSet"; + +} diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoDecorationRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoElementDecorationRenderer.java similarity index 54% rename from spring-faces/src/main/java/org/springframework/faces/ui/DojoDecorationRenderer.java rename to spring-faces/src/main/java/org/springframework/faces/ui/DojoElementDecorationRenderer.java index 0974af17..7d224642 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoDecorationRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoElementDecorationRenderer.java @@ -32,26 +32,23 @@ import org.springframework.faces.webflow.JsfUtils; * @author Jeremy Grelle * */ -public class DojoDecorationRenderer extends BaseSpringJavascriptDecorationRenderer { - - private String dojoJsResourceUri = "/dojo/dojo.js"; - - private String dijitThemePath = "/dijit/themes/"; - - private String dijitTheme = "tundra"; - - private String springDojoJsResourceUri = "/spring/Spring-Dojo.js"; +public class DojoElementDecorationRenderer extends BaseSpringJavascriptDecorationRenderer { public void encodeBegin(FacesContext context, UIComponent component) throws IOException { super.encodeBegin(context, component); if (!JsfUtils.isAsynchronousFlowRequest()) { - ResourceHelper.renderStyleLink(context, dijitThemePath + dijitTheme + "/" + dijitTheme + ".css"); - ResourceHelper.renderScriptLink(context, dojoJsResourceUri); + if (!context.getViewRoot().getAttributes().containsKey(DojoConstants.CUSTOM_THEME_PATH_SET) + && !context.getViewRoot().getAttributes().containsKey(DojoConstants.CUSTOM_THEME_SET)) { + ResourceHelper.renderStyleLink(context, DojoConstants.DIJIT_THEME_PATH + + DojoConstants.DEFAULT_DIJIT_THEME + "/" + DojoConstants.DEFAULT_DIJIT_THEME + ".css"); + } - ResourceHelper.renderScriptLink(context, springDojoJsResourceUri); + ResourceHelper.renderScriptLink(context, DojoConstants.DOJO_JS_RESOURCE_URI); + + ResourceHelper.renderScriptLink(context, DojoConstants.SPRING_DOJO_JS_RESOURCE_URI); } } @@ -59,26 +56,33 @@ public class DojoDecorationRenderer extends BaseSpringJavascriptDecorationRender ResponseWriter writer = context.getResponseWriter(); - if (component.getChildCount() == 0) - throw new FacesException("A Spring Faces advisor expects to have at least one child component."); - - UIComponent advisedChild = (UIComponent) component.getChildren().get(0); - - ResourceHelper.renderDojoInclude(context, ((DojoDecoration) component).getDojoComponentType()); + String selector; + if (component.getAttributes().containsKey("selector")) { + selector = "\"" + (String) component.getAttributes().get("selector") + "\""; + } else { + if (component.getChildCount() == 0) + throw new FacesException( + "A Spring Faces elementDecoration expects either have a specified selector or at least one child component."); + selector = "dojo.byId('" + ((UIComponent) component.getChildren().get(0)).getClientId(context) + "')"; + } ResourceHelper.beginScriptBlock(context); StringBuffer script = new StringBuffer(); + script.append(" dojo.addOnLoad(function(){dojo.query(" + selector + ").forEach(function(element){"); script.append(" Spring.addDecoration(new Spring.ElementDecoration({ "); - script.append(" elementId : '" + advisedChild.getClientId(context) + "', "); - script.append(" widgetType : '" + ((DojoDecoration) component).getDojoComponentType() + "', "); + script.append(" elementId : element, "); + script.append(" widgetType : '" + component.getAttributes().get("widgetType") + "', "); + if (component.getAttributes().containsKey("widgetModule")) { + script.append(" widgetModule : '" + component.getAttributes().get("widgetModule") + "', "); + } script.append(" widgetAttrs : { "); String dojoAttrs = getDojoAttributesAsString(context, component); script.append(dojoAttrs); - script.append(" }}));"); + script.append(" }}));})});"); writer.writeText(script, null); @@ -87,29 +91,10 @@ public class DojoDecorationRenderer extends BaseSpringJavascriptDecorationRender protected String getDojoAttributesAsString(FacesContext context, UIComponent component) { - DojoDecoration advisor = (DojoDecoration) component; - StringBuffer attrs = new StringBuffer(); - - for (int i = 0; i < advisor.getDojoAttributes().length; i++) { - - String key = advisor.getDojoAttributes()[i]; - Object value = advisor.getAttributes().get(key); - - if (value != null) { - - if (attrs.length() > 0) - attrs.append(", "); - - attrs.append(key + " : "); - - if (value instanceof String) { - attrs.append("'" + value + "'"); - } else { - attrs.append(value.toString()); - } - - } + if (component.getAttributes().containsKey("widgetAttrs")) { + return (String) component.getAttributes().get("widgetAttrs"); + } else { + return ""; } - return attrs.toString(); } } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoScriptRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoScriptRenderer.java new file mode 100644 index 00000000..0d720893 --- /dev/null +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoScriptRenderer.java @@ -0,0 +1,30 @@ +package org.springframework.faces.ui; + +import java.io.IOException; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.render.Renderer; + +import org.springframework.faces.ui.resource.ResourceHelper; + +/** + * {@link Renderer} implementation that renders the JavaScript resources required by the Dojo versions of the Spring + * Faces components. + * + * @author Jeremy Grelle + * + */ +public class DojoScriptRenderer extends Renderer { + + private static final String SPRING_JS_RESOURCE_URI = "/spring/Spring.js"; + + public void encodeBegin(FacesContext context, UIComponent component) throws IOException { + + ResourceHelper.renderScriptLink(context, SPRING_JS_RESOURCE_URI); + + ResourceHelper.renderScriptLink(context, DojoConstants.DOJO_JS_RESOURCE_URI); + + ResourceHelper.renderScriptLink(context, DojoConstants.SPRING_DOJO_JS_RESOURCE_URI); + } +} diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoStyleRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoStyleRenderer.java index c1051077..e2c041d6 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoStyleRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoStyleRenderer.java @@ -31,12 +31,25 @@ import org.springframework.faces.ui.resource.ResourceHelper; */ public class DojoStyleRenderer extends Renderer { - private static final String dijitThemePath = "/dijit/themes/"; + private static final String THEME_PATH_ATTR = "themePath"; - private static final String dijitTheme = "tundra"; + private static final String THEME_ATTR = "theme"; public void encodeBegin(FacesContext context, UIComponent component) throws IOException { - ResourceHelper.renderStyleLink(context, dijitThemePath + dijitTheme + "/" + dijitTheme + ".css"); + String themePath = DojoConstants.DIJIT_THEME_PATH; + String theme = DojoConstants.DEFAULT_DIJIT_THEME; + + if (component.getAttributes().containsKey(THEME_PATH_ATTR)) { + themePath = (String) component.getAttributes().get(THEME_PATH_ATTR); + context.getViewRoot().getAttributes().put(DojoConstants.CUSTOM_THEME_PATH_SET, Boolean.TRUE); + } + + if (component.getAttributes().containsKey(THEME_ATTR)) { + theme = (String) component.getAttributes().get(THEME_ATTR); + context.getViewRoot().getAttributes().put(DojoConstants.CUSTOM_THEME_SET, Boolean.TRUE); + } + + ResourceHelper.renderStyleLink(context, themePath + theme + "/" + theme + ".css"); } } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoDecoration.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java similarity index 95% rename from spring-faces/src/main/java/org/springframework/faces/ui/DojoDecoration.java rename to spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java index 8f517d67..2071c25c 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoDecoration.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java @@ -16,7 +16,6 @@ package org.springframework.faces.ui; import javax.faces.component.UIComponent; -import javax.faces.component.UIComponentBase; import javax.faces.context.FacesContext; import javax.faces.el.ValueBinding; @@ -27,7 +26,7 @@ import javax.faces.el.ValueBinding; * @author Jeremy Grelle * */ -public abstract class DojoDecoration extends UIComponentBase { +public abstract class DojoWidget extends SpringJavascriptElementDecoration { protected static final String[] DOJO_ATTRS = new String[] { "disabled", "intermediateChanges", "tabIndex", "required", "promptMessage", "invalidMessage", "constraints", "regExp", "regExpGen", "propercase", @@ -167,7 +166,7 @@ public abstract class DojoDecoration extends UIComponentBase { protected abstract String[] getDojoAttributes(); - public abstract String getDojoComponentType(); + public abstract String getWidgetType(); public Object saveState(FacesContext context) { Object[] values = new Object[11]; @@ -200,9 +199,4 @@ public abstract class DojoDecoration extends UIComponentBase { this.propercase = (Boolean) values[10]; } - public String getFamily() { - - return "spring.faces.Decoration"; - } - } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidgetRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidgetRenderer.java new file mode 100644 index 00000000..493a6421 --- /dev/null +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidgetRenderer.java @@ -0,0 +1,35 @@ +package org.springframework.faces.ui; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; + +public class DojoWidgetRenderer extends DojoElementDecorationRenderer { + + protected String getDojoAttributesAsString(FacesContext context, UIComponent component) { + + DojoWidget advisor = (DojoWidget) component; + StringBuffer attrs = new StringBuffer(); + + for (int i = 0; i < advisor.getDojoAttributes().length; i++) { + + String key = advisor.getDojoAttributes()[i]; + Object value = advisor.getAttributes().get(key); + + if (value != null) { + + if (attrs.length() > 0) + attrs.append(", "); + + attrs.append(key + " : "); + + if (value instanceof String) { + attrs.append("'" + value + "'"); + } else { + attrs.append(value.toString()); + } + + } + } + return attrs.toString(); + } +} diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/SpringJavascriptElementDecoration.java b/spring-faces/src/main/java/org/springframework/faces/ui/SpringJavascriptElementDecoration.java new file mode 100644 index 00000000..a2302e32 --- /dev/null +++ b/spring-faces/src/main/java/org/springframework/faces/ui/SpringJavascriptElementDecoration.java @@ -0,0 +1,12 @@ +package org.springframework.faces.ui; + +import javax.faces.component.UIComponentBase; + +public class SpringJavascriptElementDecoration extends UIComponentBase { + + public String getFamily() { + + return "spring.faces.Decoration"; + } + +} diff --git a/spring-faces/src/main/resources/META-INF/faces-config.xml b/spring-faces/src/main/resources/META-INF/faces-config.xml index 66f1f4c6..a03e4bc2 100644 --- a/spring-faces/src/main/resources/META-INF/faces-config.xml +++ b/spring-faces/src/main/resources/META-INF/faces-config.xml @@ -41,6 +41,11 @@ spring.faces.DojoIncludeStyles org.springframework.faces.ui.DynamicComponent + + + spring.faces.DojoIncludeScripts + org.springframework.faces.ui.DynamicComponent + spring.faces.ResourceGroup @@ -52,6 +57,11 @@ org.springframework.faces.ui.DynamicComponent + + spring.faces.DojoElementDecoration + org.springframework.faces.ui.SpringJavascriptElementDecoration + + spring.faces.DojoClientTextValidator org.springframework.faces.ui.DojoClientTextValidator @@ -105,8 +115,14 @@ spring.faces.Decoration - spring.faces.DojoDecorationRenderer - org.springframework.faces.ui.DojoDecorationRenderer + spring.faces.DojoWidgetRenderer + org.springframework.faces.ui.DojoWidgetRenderer + + + + spring.faces.Decoration + spring.faces.DojoElementDecorationRenderer + org.springframework.faces.ui.DojoElementDecorationRenderer @@ -121,6 +137,12 @@ org.springframework.faces.ui.DojoStyleRenderer + + spring.faces.DynamicComponent + spring.faces.DojoScriptRenderer + org.springframework.faces.ui.DojoScriptRenderer + + spring.faces.DynamicComponent spring.faces.ResourceGroupRenderer diff --git a/spring-faces/src/main/resources/META-INF/springfaces.taglib.xml b/spring-faces/src/main/resources/META-INF/springfaces.taglib.xml index 9fa82f85..b686602e 100644 --- a/spring-faces/src/main/resources/META-INF/springfaces.taglib.xml +++ b/spring-faces/src/main/resources/META-INF/springfaces.taglib.xml @@ -11,6 +11,13 @@ spring.faces.DojoStyleRenderer + + includeScripts + + spring.faces.DojoIncludeScripts + spring.faces.DojoScriptRenderer + + resourceGroup @@ -46,11 +53,20 @@ spring.faces.AjaxEventInterceptorRenderer + + + elementDecoration + + spring.faces.DojoElementDecoration + spring.faces.DojoElementDecorationRenderer + + + clientTextValidator spring.faces.DojoClientTextValidator - spring.faces.DojoDecorationRenderer + spring.faces.DojoWidgetRenderer @@ -58,7 +74,7 @@ clientNumberValidator spring.faces.DojoClientNumberValidator - spring.faces.DojoDecorationRenderer + spring.faces.DojoWidgetRenderer @@ -66,7 +82,7 @@ clientCurrencyValidator spring.faces.DojoClientCurrencyValidator - spring.faces.DojoDecorationRenderer + spring.faces.DojoWidgetRenderer @@ -74,7 +90,7 @@ clientDateValidator spring.faces.DojoClientDateValidator - spring.faces.DojoDecorationRenderer + spring.faces.DojoWidgetRenderer diff --git a/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js b/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js index 1b4141bb..001a14c1 100644 --- a/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js +++ b/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -dojo.declare("Spring.DefaultEquals",null,{equals:function(_1){if(_1.declaredClass&&_1.declaredClass==this.declaredClass){return true;}else{return false;}}});dojo.declare("Spring.ElementDecoration",[Spring.AbstractElementDecoration,Spring.DefaultEquals],{constructor:function(_2){this.copyFields=new Array("name","value","type","checked","selected","readOnly","disabled","alt","maxLength","class","title");dojo.mixin(this,_2);if(this.widgetModule==""){this.widgetModule=this.widgetType;}},apply:function(){if(dijit.byId(this.elementId)){dijit.byId(this.elementId).destroyRecursive(false);}var _3=dojo.byId(this.elementId);if(!_3){console.error("Could not apply "+this.widgetType+" decoration. Element with id '"+this.elementId+"' not found in the DOM.");}else{var _4=this.widgetAttrs["datePattern"];if(_4&&this.widgetType=="dijit.form.DateTextBox"){if(!this.widgetAttrs["value"]){this.widgetAttrs["value"]=dojo.date.locale.parse(_3.value,{selector:"date",datePattern:_4});}if(!this.widgetAttrs["serialize"]){this.widgetAttrs["serialize"]=function(d,_6){return dojo.date.locale.format(d,{selector:"date",datePattern:_4});};}}for(var _7 in this.copyFields){_7=this.copyFields[_7];if(!this.widgetAttrs[_7]&&_3[_7]&&(typeof _3[_7]!="number"||(typeof _3[_7]=="number"&&_3[_7]>=0))){this.widgetAttrs[_7]=_3[_7];}}if(_3["style"]&&_3["style"].cssText){this.widgetAttrs["style"]=_3["style"].cssText;}dojo.require(this.widgetModule);var _8=dojo.eval(this.widgetType);this.widget=new _8(this.widgetAttrs,_3);this.widget.startup();}return this;},validate:function(){if(!this.widget.isValid){return true;}var _9=this.widget.isValid(false);if(!_9){this.widget.state="Error";this.widget._setStateClass();}return _9;}});dojo.declare("Spring.ValidateAllDecoration",[Spring.AbstractValidateAllDecoration,Spring.DefaultEquals],{constructor:function(_a){this.originalHandler=null;this.connection=null;dojo.mixin(this,_a);},apply:function(){var _b=dojo.byId(this.elementId);if(!_b){console.error("Could not apply ValidateAll decoration. Element with id '"+this.elementId+"' not found in the DOM.");}else{this.originalHandler=_b[this.event];var _c=this;_b[this.event]=function(_d){_c.handleEvent(_d,_c);};}return this;},cleanup:function(){dojo.disconnect(this.connection);},handleEvent:function(_e,_f){if(!Spring.validateAll()){dojo.publish(this.elementId+"/validation",[false]);dojo.stopEvent(_e);}else{dojo.publish(this.elementId+"/validation",[true]);if(dojo.isFunction(_f.originalHandler)){var _10=_f.originalHandler(_e);if(_10==false){dojo.stopEvent(_e);}}}}});dojo.declare("Spring.AjaxEventDecoration",[Spring.AbstractAjaxEventDecoration,Spring.DefaultEquals],{constructor:function(_11){this.validationSubscription=null;this.connection=null;this.allowed=true;dojo.mixin(this,_11);},apply:function(){var _12=dojo.byId(this.elementId);if(!_12){console.error("Could not apply AjaxEvent decoration. Element with id '"+this.elementId+"' not found in the DOM.");}else{this.validationSubscription=dojo.subscribe(this.elementId+"/validation",this,"_handleValidation");this.connection=dojo.connect(_12,this.event,this,"submit");}return this;},cleanup:function(){dojo.unsubscribe(this.validationSubscription);dojo.disconnect(this.connection);},submit:function(_13){if(this.sourceId==""){this.sourceId=this.elementId;}if(this.formId==""){Spring.remoting.getLinkedResource(this.sourceId,this.params,this.popup);}else{if(this.allowed){Spring.remoting.submitForm(this.sourceId,this.formId,this.params);}}dojo.stopEvent(_13);},_handleValidation:function(_14){if(!_14){this.allowed=false;}else{this.allowed=true;}}});dojo.declare("Spring.RemotingHandler",Spring.AbstractRemotingHandler,{constructor:function(){},submitForm:function(_15,_16,_17){var _18=new Object();for(var key in _17){_18[key]=_17[key];}var _1a=dojo.byId(_15);if(_1a!=null){if(_1a.value!=undefined&&_1a.type&&("button,submit,reset").indexOf(_1a.type)<0){_18[_15]=_1a.value;}else{if(_1a.name!=undefined){_18[_1a.name]=_1a.name;}else{_18[_15]=_15;}}}if(!_18["ajaxSource"]){_18["ajaxSource"]=_15;}var _1b=dojo.byId(_16);var _1c=dojo.string.trim(_1b.method);_1c=_1c.length>0?_1c.toUpperCase():"GET";dojo.xhr(_1c,{content:_18,form:_16,handleAs:"text",headers:{"Accept":"text/html;type=ajax"},load:this.handleResponse,error:this.handleError},_1c=="POST"?true:false);},getLinkedResource:function(_1d,_1e,_1f){this.getResource(dojo.byId(_1d).href,_1e,_1f);},getResource:function(_20,_21,_22){dojo.xhrGet({url:_20,content:_21,handleAs:"text",headers:{"Accept":"text/html;type=ajax"},load:this.handleResponse,error:this.handleError,modal:_22});},handleResponse:function(_23,_24){var _25=_24.xhr.getResponseHeader("Spring-Redirect-URL");var _26=_24.xhr.getResponseHeader("Spring-Modal-View");var _27=((dojo.isString(_26)&&_26.length>0)||_24.args.modal);if(dojo.isString(_25)&&_25.length>0){if(_27){Spring.remoting.renderURLToModalDialog(_25);return _23;}else{if(_25.indexOf("/")>=0){window.location=window.location.protocol+"//"+window.location.host+_25;}else{var _28=window.location.protocol+"//"+window.location.host+window.location.pathname;var _29=_28.lastIndexOf("/");_28=_28.substr(0,_29+1)+_25;if(_28==window.location){Spring.remoting.getResource(_28,_24.args.content,false);}else{window.location=_28;}}return _23;}}var _2a="(?:)((\n|\r|.)*?)(?:)";var _2b=[];var _2c=new RegExp(_2a,"img");var _2d=new RegExp(_2a,"im");var _2e=_23.match(_2c);if(_2e!=null){for(var i=0;i<_2e.length;i++){var _30=(_2e[i].match(_2d)||["","",""])[2];_30=_30.replace(//mg,"").replace(/)*/mg,"").replace(/(/mg,"");_2b.push(_30);}}_23=_23.replace(_2c,"");var _31=dojo.doc.createElement("span");_31.id="ajaxResponse";_31.style.visibility="hidden";document.body.appendChild(_31);_31.innerHTML=_23;var _32=new dojo.NodeList(_31);var _33=_32.query("#ajaxResponse > *").orphan();_32.orphan();if(_27){Spring.remoting.renderNodeListToModalDialog(_33);}else{_33.forEach(function(_34){if(_34.id!=null&&_34.id!=""){var _35=dojo.byId(_34.id);if(!_35){console.error("An existing DOM elment with id '"+_34.id+"' could not be found for replacement.");}else{_35.parentNode.replaceChild(_34,_35);}}});}dojo.forEach(_2b,function(_36){dojo.eval(_36);});return _23;},handleError:function(_37,_38){dojo.require("dijit.Dialog");console.error("HTTP status code: ",_38.xhr.status);if(Spring.debug&&_38.xhr.status!=200){var _39=new dijit.Dialog({});dojo.connect(_39,"hide",_39,function(){this.destroyRecursive(false);});_39.domNode.style.width="80%";_39.domNode.style.height="80%";_39.domNode.style.textAlign="left";_39.setContent(_38.xhr.responseText);_39.show();}return _37;},renderURLToModalDialog:function(url){Spring.remoting.getResource(url,{},true);},renderNodeListToModalDialog:function(_3b){dojo.require("dijit.Dialog");var _3c=new dijit.Dialog({});_3c.setContent(_3b);dojo.connect(_3c,"hide",_3c,function(){this.destroyRecursive(false);});_3c.show();}});dojo.declare("Spring.CommandLinkDecoration",[Spring.AbstractCommandLinkDecoration,Spring.DefaultEquals],{constructor:function(_3d){dojo.mixin(this,_3d);},apply:function(){var _3e=dojo.byId(this.elementId);if(!dojo.hasClass(_3e,"progressiveLink")){var _3f=new dojo.NodeList(_3e);_3f.addContent(this.linkHtml,"after").orphan("*");_3e=dojo.byId(this.elementId);}_3e.submitFormFromLink=this.submitFormFromLink;return this;},submitFormFromLink:function(_40,_41,_42){var _43=[];var _44=dojo.byId(_40);var _45=document.createElement("input");_45.name=_41;_45.value="submitted";_43.push(_45);dojo.forEach(_42,function(_46){var _47=document.createElement("input");_47.name=_46.name;_47.value=_46.value;_43.push(_47);});dojo.forEach(_43,function(_48){dojo.addClass(_48,"SpringLinkInput");dojo.place(_48,_44,"last");});if((_44.onsubmit?!_44.onsubmit():false)||!_44.submit()){dojo.forEach(_43,function(_49){_49.parentNode.removeChild(_49);});}}});dojo.addOnLoad(Spring.initialize); \ No newline at end of file +dojo.declare("Spring.DefaultEquals",null,{equals:function(_1){if(_1.declaredClass&&_1.declaredClass==this.declaredClass){return true;}else{return false;}}});dojo.declare("Spring.ElementDecoration",[Spring.AbstractElementDecoration,Spring.DefaultEquals],{constructor:function(_2){this.copyFields=new Array("name","value","type","checked","selected","readOnly","disabled","alt","maxLength","class","title");dojo.mixin(this,_2);this.element=dojo.byId(this.elementId);this.elementId=dojo.isString(this.elementId)?this.elementId:this.elementId.id;if(this.widgetModule==""){this.widgetModule=this.widgetType;}},apply:function(){if(dijit.byId(this.elementId)){dijit.byId(this.elementId).destroyRecursive(false);}if(!this.element){console.error("Could not apply "+this.widgetType+" decoration. Element with id '"+this.elementId+"' not found in the DOM.");}else{var _3=this.widgetAttrs["datePattern"];if(_3&&this.widgetType=="dijit.form.DateTextBox"){if(!this.widgetAttrs["value"]){this.widgetAttrs["value"]=dojo.date.locale.parse(this.element.value,{selector:"date",datePattern:_3});}if(!this.widgetAttrs["serialize"]){this.widgetAttrs["serialize"]=function(d,_5){return dojo.date.locale.format(d,{selector:"date",datePattern:_3});};}}for(var _6 in this.copyFields){_6=this.copyFields[_6];if(!this.widgetAttrs[_6]&&this.element[_6]&&(typeof this.element[_6]!="number"||(typeof this.element[_6]=="number"&&this.element[_6]>=0))){this.widgetAttrs[_6]=this.element[_6];}}if(this.element["style"]&&this.element["style"].cssText){this.widgetAttrs["style"]=this.element["style"].cssText;}dojo.require(this.widgetModule);var _7=dojo.eval(this.widgetType);this.widget=new _7(this.widgetAttrs,this.element);this.widget.startup();}return this;},validate:function(){if(!this.widget.isValid){return true;}var _8=this.widget.isValid(false);if(!_8){this.widget.state="Error";this.widget._setStateClass();}return _8;}});dojo.declare("Spring.ValidateAllDecoration",[Spring.AbstractValidateAllDecoration,Spring.DefaultEquals],{constructor:function(_9){this.originalHandler=null;this.connection=null;dojo.mixin(this,_9);},apply:function(){var _a=dojo.byId(this.elementId);if(!_a){console.error("Could not apply ValidateAll decoration. Element with id '"+this.elementId+"' not found in the DOM.");}else{this.originalHandler=_a[this.event];var _b=this;_a[this.event]=function(_c){_b.handleEvent(_c,_b);};}return this;},cleanup:function(){dojo.disconnect(this.connection);},handleEvent:function(_d,_e){if(!Spring.validateAll()){dojo.publish(this.elementId+"/validation",[false]);dojo.stopEvent(_d);}else{dojo.publish(this.elementId+"/validation",[true]);if(dojo.isFunction(_e.originalHandler)){var _f=_e.originalHandler(_d);if(_f==false){dojo.stopEvent(_d);}}}}});dojo.declare("Spring.AjaxEventDecoration",[Spring.AbstractAjaxEventDecoration,Spring.DefaultEquals],{constructor:function(_10){this.validationSubscription=null;this.connection=null;this.allowed=true;dojo.mixin(this,_10);},apply:function(){var _11=dijit.byId(this.elementId)?dijit.byId(this.elementId):dojo.byId(this.elementId);if(!_11){console.error("Could not apply AjaxEvent decoration. Element with id '"+this.elementId+"' not found in the DOM.");}else{this.validationSubscription=dojo.subscribe(this.elementId+"/validation",this,"_handleValidation");this.connection=dojo.connect(_11,this.event,this,"submit");}return this;},cleanup:function(){dojo.unsubscribe(this.validationSubscription);dojo.disconnect(this.connection);},submit:function(_12){if(this.sourceId==""){this.sourceId=this.elementId;}if(this.formId==""){Spring.remoting.getLinkedResource(this.sourceId,this.params,this.popup);}else{if(this.allowed){Spring.remoting.submitForm(this.sourceId,this.formId,this.params);}}if(_12.cancelable){dojo.stopEvent(_12);}},_handleValidation:function(_13){if(!_13){this.allowed=false;}else{this.allowed=true;}}});dojo.declare("Spring.RemotingHandler",Spring.AbstractRemotingHandler,{constructor:function(){},submitForm:function(_14,_15,_16){var _17=new Object();for(var key in _16){_17[key]=_16[key];}var _19=dojo.byId(_14);if(_19!=null){if(_19.value!=undefined&&_19.type&&("button,submit,reset").indexOf(_19.type)<0){_17[_14]=_19.value;}else{if(_19.name!=undefined){_17[_19.name]=_19.name;}else{_17[_14]=_14;}}}if(!_17["ajaxSource"]){_17["ajaxSource"]=_14;}var _1a=dojo.byId(_15);var _1b=dojo.string.trim(_1a.method);_1b=_1b.length>0?_1b.toUpperCase():"GET";dojo.xhr(_1b,{content:_17,form:_15,handleAs:"text",headers:{"Accept":"text/html;type=ajax"},load:this.handleResponse,error:this.handleError},_1b=="POST"?true:false);},getLinkedResource:function(_1c,_1d,_1e){this.getResource(dojo.byId(_1c).href,_1d,_1e);},getResource:function(_1f,_20,_21){dojo.xhrGet({url:_1f,content:_20,handleAs:"text",headers:{"Accept":"text/html;type=ajax"},load:this.handleResponse,error:this.handleError,modal:_21});},handleResponse:function(_22,_23){var _24=_23.xhr.getResponseHeader("Spring-Redirect-URL");var _25=_23.xhr.getResponseHeader("Spring-Modal-View");var _26=((dojo.isString(_25)&&_25.length>0)||_23.args.modal);if(dojo.isString(_24)&&_24.length>0){if(_26){Spring.remoting.renderURLToModalDialog(_24);return _22;}else{if(_24.indexOf("/")>=0){window.location=window.location.protocol+"//"+window.location.host+_24;}else{var _27=window.location.protocol+"//"+window.location.host+window.location.pathname;var _28=_27.lastIndexOf("/");_27=_27.substr(0,_28+1)+_24;if(_27==window.location){Spring.remoting.getResource(_27,_23.args.content,false);}else{window.location=_27;}}return _22;}}var _29="(?:)((\n|\r|.)*?)(?:)";var _2a=[];var _2b=new RegExp(_29,"img");var _2c=new RegExp(_29,"im");var _2d=_22.match(_2b);if(_2d!=null){for(var i=0;i<_2d.length;i++){var _2f=(_2d[i].match(_2c)||["","",""])[2];_2f=_2f.replace(//mg,"").replace(/)*/mg,"").replace(/(/mg,"");_2a.push(_2f);}}_22=_22.replace(_2b,"");var _30=dojo.doc.createElement("span");_30.id="ajaxResponse";_30.style.visibility="hidden";document.body.appendChild(_30);_30.innerHTML=_22;var _31=new dojo.NodeList(_30);var _32=_31.query("#ajaxResponse > *").orphan();_31.orphan();if(_26){Spring.remoting.renderNodeListToModalDialog(_32);}else{_32.forEach(function(_33){if(_33.id!=null&&_33.id!=""){var _34=dijit.byId(_33.id)?dijit.byId(_33.id).domNode:dojo.byId(_33.id);if(!_34){console.error("An existing DOM elment with id '"+_33.id+"' could not be found for replacement.");}else{_34.parentNode.replaceChild(_33,_34);}}});}dojo.forEach(_2a,function(_35){dojo.eval(_35);});return _22;},handleError:function(_36,_37){dojo.require("dijit.Dialog");console.error("HTTP status code: ",_37.xhr.status);if(Spring.debug&&_37.xhr.status!=200){var _38=new dijit.Dialog({});dojo.connect(_38,"hide",_38,function(){this.destroyRecursive(false);});_38.domNode.style.width="80%";_38.domNode.style.height="80%";_38.domNode.style.textAlign="left";_38.setContent(_37.xhr.responseText);_38.show();}return _36;},renderURLToModalDialog:function(url){Spring.remoting.getResource(url,{},true);},renderNodeListToModalDialog:function(_3a){dojo.require("dijit.Dialog");var _3b=new dijit.Dialog({});_3b.setContent(_3a);dojo.connect(_3b,"hide",_3b,function(){this.destroyRecursive(false);});_3b.show();}});dojo.declare("Spring.CommandLinkDecoration",[Spring.AbstractCommandLinkDecoration,Spring.DefaultEquals],{constructor:function(_3c){dojo.mixin(this,_3c);},apply:function(){var _3d=dojo.byId(this.elementId);if(!dojo.hasClass(_3d,"progressiveLink")){var _3e=new dojo.NodeList(_3d);_3e.addContent(this.linkHtml,"after").orphan("*");_3d=dojo.byId(this.elementId);}_3d.submitFormFromLink=this.submitFormFromLink;return this;},submitFormFromLink:function(_3f,_40,_41){var _42=[];var _43=dojo.byId(_3f);var _44=document.createElement("input");_44.name=_40;_44.value="submitted";_42.push(_44);dojo.forEach(_41,function(_45){var _46=document.createElement("input");_46.name=_45.name;_46.value=_45.value;_42.push(_46);});dojo.forEach(_42,function(_47){dojo.addClass(_47,"SpringLinkInput");dojo.place(_47,_43,"last");});if((_43.onsubmit?!_43.onsubmit():false)||!_43.submit()){dojo.forEach(_42,function(_48){_48.parentNode.removeChild(_48);});}}});dojo.addOnLoad(Spring.initialize); \ No newline at end of file diff --git a/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js.uncompressed.js b/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js.uncompressed.js index 40d16588..76ea9d4c 100644 --- a/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js.uncompressed.js +++ b/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js.uncompressed.js @@ -27,6 +27,8 @@ dojo.declare("Spring.ElementDecoration", [Spring.AbstractElementDecoration, Spri constructor : function(config) { this.copyFields = new Array('name', 'value', 'type', 'checked', 'selected', 'readOnly', 'disabled', 'alt', 'maxLength', 'class', 'title'); dojo.mixin(this, config); + this.element = dojo.byId(this.elementId); + this.elementId = dojo.isString(this.elementId) ? this.elementId : this.elementId.id; if(this.widgetModule == "") { this.widgetModule = this.widgetType; } @@ -36,15 +38,15 @@ dojo.declare("Spring.ElementDecoration", [Spring.AbstractElementDecoration, Spri if (dijit.byId(this.elementId)) { dijit.byId(this.elementId).destroyRecursive(false); } - var element = dojo.byId(this.elementId); - if (!element) { + + if (!this.element) { console.error("Could not apply " + this.widgetType + " decoration. Element with id '" + this.elementId + "' not found in the DOM."); } else { var datePattern = this.widgetAttrs['datePattern']; if (datePattern && this.widgetType == 'dijit.form.DateTextBox') { if (!this.widgetAttrs['value']) { - this.widgetAttrs['value'] = dojo.date.locale.parse(element.value, {selector : "date", datePattern : datePattern}); + this.widgetAttrs['value'] = dojo.date.locale.parse(this.element.value, {selector : "date", datePattern : datePattern}); } if (!this.widgetAttrs['serialize']) { this.widgetAttrs['serialize'] = function(d, options){ @@ -54,18 +56,18 @@ dojo.declare("Spring.ElementDecoration", [Spring.AbstractElementDecoration, Spri } 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]; + if (!this.widgetAttrs[copyField] && this.element[copyField] && + (typeof this.element[copyField] != 'number' || + (typeof this.element[copyField] == 'number' && this.element[copyField] >= 0))) { + this.widgetAttrs[copyField] = this.element[copyField]; } } - if(element['style'] && element['style'].cssText){ - this.widgetAttrs['style'] = element['style'].cssText; + if(this.element['style'] && this.element['style'].cssText){ + this.widgetAttrs['style'] = this.element['style'].cssText; } dojo.require(this.widgetModule); var widgetConstructor = dojo.eval(this.widgetType); - this.widget = new widgetConstructor(this.widgetAttrs, element); + this.widget = new widgetConstructor(this.widgetAttrs, this.element); this.widget.startup(); } //return this to support method chaining @@ -136,7 +138,8 @@ dojo.declare("Spring.AjaxEventDecoration", [Spring.AbstractAjaxEventDecoration, }, apply : function() { - var element = dojo.byId(this.elementId); + + var element = dijit.byId(this.elementId) ? dijit.byId(this.elementId) : dojo.byId(this.elementId); if (!element) { console.error("Could not apply AjaxEvent decoration. Element with id '" + this.elementId + "' not found in the DOM."); } else { @@ -162,7 +165,9 @@ dojo.declare("Spring.AjaxEventDecoration", [Spring.AbstractAjaxEventDecoration, Spring.remoting.submitForm(this.sourceId, this.formId, this.params); } } - dojo.stopEvent(event); + if (event.cancelable) { + dojo.stopEvent(event); + } }, _handleValidation : function(success){ @@ -314,7 +319,7 @@ dojo.declare("Spring.RemotingHandler", Spring.AbstractRemotingHandler, { //Insert the new DOM nodes and update the Form's action URL newNodes.forEach(function(item){ if (item.id != null && item.id != "") { - var target = dojo.byId(item.id); + var target = dijit.byId(item.id) ? dijit.byId(item.id).domNode : dojo.byId(item.id); if (!target) { console.error("An existing DOM elment with id '" + item.id + "' could not be found for replacement."); } else {