Details
-
Type: Improvement
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 2.0-Alpha3
-
Fix Version/s: EE-3.2.0.GA, 3.3
-
Component/s: ACE-Components
-
Labels:None
-
Environment:ICEfaces 2
-
Affects:Documentation (User Guide, Ref. Guide, etc.)
Description
We need a way to declare static javascript and css dependencies in our component metadata.
For example, in org.icefaces.component.slider.Slider we have this method called from the constructor:
private void loadDependency(FacesContext context) {
context.getViewRoot().addComponentResource(context, new UIOutput() {
public void encodeBegin(FacesContext context) throws IOException {
ResponseWriter writer = context.getResponseWriter();
writer.startElement("script", this);
writer.writeAttribute("type", "text/javascript", null);
writer.writeAttribute("src", "http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js", null);
writer.endElement("script");
}
}, "head");
}
Here we're manually coding a javascript dependency on http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js which could be represented as an annotation on SliderMeta, and then this method could be generated in SliderBase.
Above that, we use the new JSF 2.0 annotations for declaring resources to be served out of our own component JAR:
@ResourceDependencies({
@ResourceDependency(name="util.js",library="org.icefaces.component.util"),
@ResourceDependency(name="yui3.js",library="org.icefaces.component.util"),
@ResourceDependency(name="slider.js",library="org.icefaces.component.slider")
})
Again, it would be nice if we could specify some annotation on SliderMeta, which would then generate this code on SliderBase.
For example, in org.icefaces.component.slider.Slider we have this method called from the constructor:
private void loadDependency(FacesContext context) {
context.getViewRoot().addComponentResource(context, new UIOutput() {
public void encodeBegin(FacesContext context) throws IOException {
ResponseWriter writer = context.getResponseWriter();
writer.startElement("script", this);
writer.writeAttribute("type", "text/javascript", null);
writer.writeAttribute("src", "http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js", null);
writer.endElement("script");
}
}, "head");
}
Here we're manually coding a javascript dependency on http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js which could be represented as an annotation on SliderMeta, and then this method could be generated in SliderBase.
Above that, we use the new JSF 2.0 annotations for declaring resources to be served out of our own component JAR:
@ResourceDependencies({
@ResourceDependency(name="util.js",library="org.icefaces.component.util"),
@ResourceDependency(name="yui3.js",library="org.icefaces.component.util"),
@ResourceDependency(name="slider.js",library="org.icefaces.component.slider")
})
Again, it would be nice if we could specify some annotation on SliderMeta, which would then generate this code on SliderBase.
Issue Links
- depends on
-
ICE-5698 Sparkle: Establish local copies of required YUI libraries
- Closed
It may be possible for the component generator to scan the component annotations and produce a single unified .js file at compile time.