Monday, July 28, 2014

Re: Best way to share common css defs in a GWT application with multi-module

So if I define a color in common.css like this:
@def black #000;
I can reuse the black definition in Foo e Bar CssResources?


On Monday, July 28, 2014 2:43:35 PM UTC+2, Davide Micheletti wrote:

The easiest way to do this is to create a common module that the two modules inherit.  You would put the CSS in the parent, and include it from both the child modules.
Here is an example.  Suppose you have two modules: com.company.apps.foo.Foo and com.company.apps.bar.Bar.  These would have the following Java source tree:
src/
    com/
        company/
            apps/
                foo/
                    Foo.gwt.xml 
                    client/Foo.java
                    public/Foo.html
                bar/
                    Bar.gwt.xml
                    client/Bar.java
                    public/Bar.html
You want to put "company.css" somewhere where it is available to both.  To do this, you might create a new directory: like src/com/company/apps/public/ and then put your company.css file in there.  You would then need to create a GWT module for Foo and Bar to inherit from.  Your new tree would look like this: 
src/
    com/
        company/
            apps/
                public/company.css
                Common.gwt.xml
                foo/
                    Foo.gwt.xml
                    client/Foo.java
                    public/Foo.html
                bar/
                    Bar.gwt.xml
                    client/Bar.java
                    public/Bar.html
Common.gwt.xml would look something like this:
<module>
<inherits name="com.google.gwt.user.User"/>
<public path="public"/>
</module>
Then you would add a line like this to Foo.gwt.xml and Bar.gwt.xml:
<inherits name="com.company.apps.Common"/>
This will cause Foo and Bar to inherit all the settings from Common.  The particular setting you are interested in will be the 'public' directory from Common, which contains your shared CSS file. 
Give that a try, and see if it works for you!  Hope that helps,
- Dan Morrill


Regards

Davide


On Mon, Jul 28, 2014 at 1:52 PM, Federico De Faveri <defa...@gmail.com> wrote:
I've a GWT application split in multiple modules. 
I need to share a set of common defs, a color palette for example, between cssresources and uibinder files in different modules.
How can I do it?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment