SWF-965 - We should be able to change the css style of the code generated by SF: tags.
SWF-1020 - Add an <sf:elementDecoration> component to make it easy to build new Dojo-based composition components
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,6 +41,11 @@
|
||||
<component-type>spring.faces.DojoIncludeStyles</component-type>
|
||||
<component-class>org.springframework.faces.ui.DynamicComponent</component-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<component-type>spring.faces.DojoIncludeScripts</component-type>
|
||||
<component-class>org.springframework.faces.ui.DynamicComponent</component-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<component-type>spring.faces.ResourceGroup</component-type>
|
||||
@@ -52,6 +57,11 @@
|
||||
<component-class>org.springframework.faces.ui.DynamicComponent</component-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<component-type>spring.faces.DojoElementDecoration</component-type>
|
||||
<component-class>org.springframework.faces.ui.SpringJavascriptElementDecoration</component-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<component-type>spring.faces.DojoClientTextValidator</component-type>
|
||||
<component-class>org.springframework.faces.ui.DojoClientTextValidator</component-class>
|
||||
@@ -105,8 +115,14 @@
|
||||
|
||||
<renderer>
|
||||
<component-family>spring.faces.Decoration</component-family>
|
||||
<renderer-type>spring.faces.DojoDecorationRenderer</renderer-type>
|
||||
<renderer-class>org.springframework.faces.ui.DojoDecorationRenderer</renderer-class>
|
||||
<renderer-type>spring.faces.DojoWidgetRenderer</renderer-type>
|
||||
<renderer-class>org.springframework.faces.ui.DojoWidgetRenderer</renderer-class>
|
||||
</renderer>
|
||||
|
||||
<renderer>
|
||||
<component-family>spring.faces.Decoration</component-family>
|
||||
<renderer-type>spring.faces.DojoElementDecorationRenderer</renderer-type>
|
||||
<renderer-class>org.springframework.faces.ui.DojoElementDecorationRenderer</renderer-class>
|
||||
</renderer>
|
||||
|
||||
<renderer>
|
||||
@@ -121,6 +137,12 @@
|
||||
<renderer-class>org.springframework.faces.ui.DojoStyleRenderer</renderer-class>
|
||||
</renderer>
|
||||
|
||||
<renderer>
|
||||
<component-family>spring.faces.DynamicComponent</component-family>
|
||||
<renderer-type>spring.faces.DojoScriptRenderer</renderer-type>
|
||||
<renderer-class>org.springframework.faces.ui.DojoScriptRenderer</renderer-class>
|
||||
</renderer>
|
||||
|
||||
<renderer>
|
||||
<component-family>spring.faces.DynamicComponent</component-family>
|
||||
<renderer-type>spring.faces.ResourceGroupRenderer</renderer-type>
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
<renderer-type>spring.faces.DojoStyleRenderer</renderer-type>
|
||||
</component>
|
||||
</tag>
|
||||
<tag>
|
||||
<tag-name>includeScripts</tag-name>
|
||||
<component>
|
||||
<component-type>spring.faces.DojoIncludeScripts</component-type>
|
||||
<renderer-type>spring.faces.DojoScriptRenderer</renderer-type>
|
||||
</component>
|
||||
</tag>
|
||||
<tag>
|
||||
<tag-name>resourceGroup</tag-name>
|
||||
<component>
|
||||
@@ -46,11 +53,20 @@
|
||||
<renderer-type>spring.faces.AjaxEventInterceptorRenderer</renderer-type>
|
||||
</component>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>elementDecoration</tag-name>
|
||||
<component>
|
||||
<component-type>spring.faces.DojoElementDecoration</component-type>
|
||||
<renderer-type>spring.faces.DojoElementDecorationRenderer</renderer-type>
|
||||
</component>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
<tag-name>clientTextValidator</tag-name>
|
||||
<component>
|
||||
<component-type>spring.faces.DojoClientTextValidator</component-type>
|
||||
<renderer-type>spring.faces.DojoDecorationRenderer</renderer-type>
|
||||
<renderer-type>spring.faces.DojoWidgetRenderer</renderer-type>
|
||||
</component>
|
||||
</tag>
|
||||
|
||||
@@ -58,7 +74,7 @@
|
||||
<tag-name>clientNumberValidator</tag-name>
|
||||
<component>
|
||||
<component-type>spring.faces.DojoClientNumberValidator</component-type>
|
||||
<renderer-type>spring.faces.DojoDecorationRenderer</renderer-type>
|
||||
<renderer-type>spring.faces.DojoWidgetRenderer</renderer-type>
|
||||
</component>
|
||||
</tag>
|
||||
|
||||
@@ -66,7 +82,7 @@
|
||||
<tag-name>clientCurrencyValidator</tag-name>
|
||||
<component>
|
||||
<component-type>spring.faces.DojoClientCurrencyValidator</component-type>
|
||||
<renderer-type>spring.faces.DojoDecorationRenderer</renderer-type>
|
||||
<renderer-type>spring.faces.DojoWidgetRenderer</renderer-type>
|
||||
</component>
|
||||
</tag>
|
||||
|
||||
@@ -74,7 +90,7 @@
|
||||
<tag-name>clientDateValidator</tag-name>
|
||||
<component>
|
||||
<component-type>spring.faces.DojoClientDateValidator</component-type>
|
||||
<renderer-type>spring.faces.DojoDecorationRenderer</renderer-type>
|
||||
<renderer-type>spring.faces.DojoWidgetRenderer</renderer-type>
|
||||
</component>
|
||||
</tag>
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user