This has been bugging me all day and I finally found a workaround that
appears to work but I want to know if anyone knows a better way of
getting the <ui:style> code that you declare in a *.ui.xml file for
use with UIBinder  to be injected immediately, when the widget is
created, instead of, what seems to be, deferred till the end of the
current event cycle (from what I've read and experienced). I would
have hoped there would be an attribute or flag that can be set on the
<ui:style> to make sure its injected straight away but I haven't found
anything.

I basically decided to convert one of my widget earlier today to use
UIBinder, thinking it would be a quick job, but unfortunately it broke
the layout of the widget because my particular widget is positioned on
the screen right after being created, which basically needs the style
sheet code applied so I can evaluate the widgets width accurately.

Calling style.ensureInjected() implicitly didn't fix the problem, so I
initially moved the style code to a ResourceBundle and got that
injected at an earlier stage in my app which did the trick, except I
preferred to keep the style code in the .ui.xml file.

I then found a mention on this group that the StyleInjector can be
used directly and has a parameter to force immediate injection, like:

StyleInjector.inject( style.getText(), true );

This allowed me to move the style back to the .ui.xml file but that
doesn't ensure its only injected once. I create several of these
widgets and sure enough, they each injected the same style code.

The only way around this, and my final solution unless anyone can
suggest something I'm missing, is to have a static boolean in the
widget to record that the stylesheet has been injected already, which
gets me what I wanted - I just hoped there would be a simpler way to
do it.

-- 
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