I agree with Timothy that GWT as a framework makes almost impossible to create "runtime themeable"  application. While doing with plain js is pretty straight forward, here is what we did:

in the index.html
<link id="vt0" href="" rel="stylesheet" type="text/css" title="STANDARD"/>
<link id="vt1" href="" rel="alternate stylesheet" type="text/css" title="CUSTOM"/>

then in code:
eventBus.addHandler(SelectViewTypeEvent.TYPE, new SelectViewTypeEvent.Handler() {
    @Override
    public void onViewTypeChanged(SelectViewTypeEvent event) {
        final int viewTypeOrdinal = event.getViewType().ordinal();
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            @Override
            public void execute() {
                Document doc = Document.get();
                for(ViewType vt : ViewType.values()) {
                    LinkElement link = doc.getElementById("vt" + vt.ordinal()).cast();
                    link.setDisabled(vt.ordinal() != viewTypeOrdinal);
                }
            }
        });
    }
});

to properly work on IE browsers, before render anything:
private void disableAllStylesheetsForIE() {
    final Document doc = Document.get();
    for(ViewType vt : ViewType.values()) {
        LinkElement link = doc.getElementById("vt" + vt.ordinal()).cast();
        link.setDisabled(true);
    }
    LinkElement link = doc.getElementById("vt0").cast();
    link.setDisabled(false);
}



My wish is that some day, I'll would be able to use all GWT-CSS goodies like image bundles/sprites and css class hashing, etc for this kind of apps.

IMHO css should be orthogonal to the actual html generated. Although, in the current times of HTML5 apps, css is part of the behavior of widgets, so in widgets based frameworks we have a tension between how a widget should look (web designer job) and its behavior that is some cases also partly implemented in css (mostly because css is hardware accelerated, like css3 transformation or animations, and plain js doesn't).

Regards,
--
Bauna


On 05/16/2013 06:00 AM, Thomas Broyer wrote:


On Thursday, May 16, 2013 10:44:33 AM UTC+2, Timothy Spear wrote:
Inline style in each UiBinder xml file will not be maintainable.
From a code maintenance perspective stylesheets should be used extensively.

I find it much better for maintainability if the styles for a given "widget" is close to that widget, and there's nothing closer than "in the same file".
Let's just agree that we disagree on this point.
 
The suggested solution for this is to include the css as part of the ClientBundle as a resource.
This suggested solution is predicated on the following assumptions:
-- a single CSS file (yes you can have multiple files, but this is MX nightmare. Which variable.....
-- User does not have the ability to change/select alternate CSS files
-- Prevents the application from being re-labeled by an OEM SaaS unless you also provide source code
-- Now you have to maintain and keep in sync three separate items. Class name in CSS, Variable Names in CssResource file, declarations in UiBinder XML File

Now explain all the linkages to a junior developer who needs to change one minor thing in a complex app.

Nothing prevents you from using "plain old CSS": link to the stylesheet from your HTML host page (and use SASS/LESS/whatever if you like) and use your class names in your UiBinder.
That's the only way to have swappable/updatable styles without handing out the source code; and it's not different than how you'd do it if you were using a pure-JS framework. GWT doesn't make anything "more complicated" here.
--
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply via email to