Adding an <includStyles> tag for enabling proper inclusion of the stylesheets required by Spring Faces components in the <head>

This commit is contained in:
Jeremy Grelle
2008-03-20 15:01:35 +00:00
parent d6b8d44d28
commit 243ee05f1a
4 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
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;
public class DojoStyleRenderer extends Renderer {
private String dijitThemePath = "/dijit/themes/";
private String dijitTheme = "tundra";
private ResourceHelper resourceHelper = new ResourceHelper();
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
resourceHelper.renderStyleLink(context, dijitThemePath + dijitTheme + "/" + dijitTheme + ".css");
}
}

View File

@@ -0,0 +1,11 @@
package org.springframework.faces.ui;
import javax.faces.component.UIComponentBase;
public class DynamicComponent extends UIComponentBase {
public String getFamily() {
return "spring.faces.DynamicComponent";
}
}

View File

@@ -37,6 +37,11 @@
<component-class>org.springframework.faces.ui.AjaxEventInterceptor</component-class>
</component>
<component>
<component-type>spring.faces.DojoIncludeStyles</component-type>
<component-class>org.springframework.faces.ui.DynamicComponent</component-class>
</component>
<component>
<component-type>spring.faces.DojoClientTextValidator</component-type>
<component-class>org.springframework.faces.ui.DojoClientTextValidator</component-class>
@@ -120,6 +125,12 @@
<renderer-type>spring.faces.ValidateAll</renderer-type>
<renderer-class>org.springframework.faces.ui.ValidateAllRenderer</renderer-class>
</renderer>
<renderer>
<component-family>spring.faces.DynamicComponent</component-family>
<renderer-type>spring.faces.DojoStyleRenderer</renderer-type>
<renderer-class>org.springframework.faces.ui.DojoStyleRenderer</renderer-class>
</renderer>
</render-kit>
</faces-config>

View File

@@ -4,6 +4,13 @@
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>http://www.springframework.org/tags/faces</namespace>
<tag>
<tag-name>includeStyles</tag-name>
<component>
<component-type>spring.faces.DojoIncludeStyles</component-type>
<renderer-type>spring.faces.DojoStyleRenderer</renderer-type>
</component>
</tag>
<tag>
<tag-name>commandButton</tag-name>
<component>