On Thursday, January 13, 2011 11:15:52 PM UTC-8, zixzigma wrote:
>
> do you think there is a better way to do this ? 
> this  "resources.style().ensureInjected()" 
> sitting on one line, on its own, seems a bit suspecious, 
>
> is this the correct way of using css resources inside client bundle ? 

everytime we want to use it, call ensureInjected() ? 

 


Styles need to be injected into DOM only once. Typically, MyResources would 
be a singleton. There would be a static constructor somewhere:

static {
  resources = GWT.create(MyResources.class);
  resources.style.ensureInjected()
}

Calling ensureInjected in the entry point works too.

1- does this mean, we no longer have to include a CSS file in our 
> main .html file ?

 
The styles can be included in .html file, but having them in a bundle allows 
packing the styles together with your components (similar to using 
<ui:style/> in *.ui.xml)

2- in development when we need to manipulate the styles associated 
> with widgets, 
>    for example when a notification area needs to change colors, red/ 
> green/yellow for warning messages, 
>    is it a good idea to manipulate CSS through ClientBundle ? 
>


Yes, according to the guidelines
http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html#Programmatic_access

 

> 3- if we don't use features such as @define, @... , and stick to css, 
> is there a still valid case to use ClientBundle 
> for the sake of having access to CSS, to manipulate widgets that way ? 
>

When we use <ui:style/> in *.ui.xml, CssResource and ClientBundle are 
generated for us anyway, and there is a way to access them from code (the 
link above).  So we are already stuck to the ClientBundle anyway :-)


 

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