The postings on this site are the contributor's and don’t necessarily represent IBM’s positions, strategies or opinions.
September 28th, 2008 Alex Moffat Posted in GWT | No Comments »
Just a quick post to present the final version of the generator code for now. The next step is more extensive testing and I’ll report on that later. I had to change the format for the annotation used to define the CSS so that it included the package for the directory the CSS files are in at compile time. This was needed to support hosted mode use. Take a look at the example below
public interface CssExample extends CssResources {
@Source(resourcePackage="com.lombardi.gwtexample.generatoruser.public",
resource={"FileOne.css", "FileTwo.css"})
public void setStyle();
}
This says that setStyle() will include the CSS from FileOne.css and FileTwo.css and that these files are in the com.lombardi.gwtexample.generatoruser.public package at compile time. When links are generated they don’t include the resourcePackage value so the example above generates.
public void setStyle() {
CssResourcesHelper.addLinkToStyleSheet("FileOne.css");
CssResourcesHelper.addLinkToStyleSheet("FileTwo.css");
}
The methods defined in the interface must return void and take no arguments.
If you want to have browser specific CSS included then the browser specific files must be named by appending _<user.agent> to the existing files. For example FileOne_ie6.css or FileOne_safari.css. Possible values for user.agent are defined in UserAgent.gwt.xml. The generator also handles @import statements in the CSS files it reads.
To use the generator you need to inherit the com.lombardi.gwtexample.generator.CssGenerator.
Download the generator source code as a zip file.
Leave a Reply