Hello! I'm new in GWT development and need some help. I use GWT 2.0
and want define once some constant. For example, I need to define
mainColor = #rrggbb and want use it in various places, like CSS,
MyWidget, MyWidget.ui.xml, etc.

I read about CssResource, read about working with CSS docs, but can't
understand, what rule is the best.

Now my idea realized like this:

GlobalRes.java:
-----------------------------------------------------------------------------------------
public class GlobalRes {

        static public int gap = 10;

        static public String getGap() {
                return gap + "px";
        }

        static public String getDoubleGap() {
                return (gap * 2) + "px";
        }

        static public String mainColor() {
                return "#e6dbcf";
        }
}
-----------------------------------------------------------------------------------------


ControlPanel.css:
-----------------------------------------------------------------------------------------
@eval gap admin.client.GlobalRes.getGap();
@eval gap2 admin.client.GlobalRes.getDoubleGap();
@eval mainColor admin.client.GlobalRes.mainColor();

body {
        padding: gap;
}

.header {
        background: mainColor;
        margin-bottom: gap2;
}
-----------------------------------------------------------------------------------------

I can use variables like 'gap' and 'gap2' in many places. If I prefer,
I can change this gap in 1 place (GlobalRes.java) and value changed in
100 places. But it has bottleneck. First lines in ControlPanel.css I
must repeat in other CSS-files.

There is my question: I miss some docs and my code is little stupid?
Anyone can help me?

Thanks for any answer,
Pavel.

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


Reply via email to