Good question - one situation that comes to my mind is when you want to use styles from some global stylesheet in a UiBinder template - then you need to call ensureInjected
to... ensure the styles are indeed injected when you are referencing them (the "local" UiBinder styles, that you define in xml are automagically injected).
You can see this used as such in the Mail example:
public void onModuleLoad() {
// Inject global styles.
GWT.<GlobalResources>create(GlobalResources.class).css().ensureInjected();
// Create the UI defined in Mail.ui.xml.
DockLayoutPanel outer = binder.createAndBindUi(this);
// ...rest of the code
}
Note how ensureInjected
is called before binding the UI.
This is the only situation I know that warrants using ensureInjected
, but maybe I missed something.