1 / 7

CssResource

CssResource. escribes CssResource  and the compile-time processing of CSS. reference. http://code.google.com/p/google-web-toolkit/wiki/CssResource#External https://developers.google.com/web-toolkit/doc/latest/DevGuideClientBundle. Resource C ategory.

galia
Download Presentation

CssResource

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CssResource escribesCssResource and the compile-time processing of CSS

  2. reference • http://code.google.com/p/google-web-toolkit/wiki/CssResource#External • https://developers.google.com/web-toolkit/doc/latest/DevGuideClientBundle

  3. Resource Category • The resources in a deployed GWT application can be roughly categorized into resources to • never cache (.nocache.js), • cache forever (.cache.html), • and everything else (myapp.css). • TheClientBundle interface • moves entries from the everything-else category into the cache-forever category.

  4. Processing of CSS • Write a CSS file, with or without GWT-specific extensions • If GWT-specific extensions are used, define a custom subtype of CssResource • Declare a method that returns CssResource or a subtype in an ClientBundle • When the bundle type is generated with GWT.create() a Java expression that evaluates to the contents of the stylesheets will be created • Except in the simplest case where the Java expression is a string literal, it is generally not the case that a CSS file could be generated into the module output • At runtime, call CssResource.ensureInjected() to inject the contents of the stylesheet • This method is safe to call multiple times, as subsequent invocations will be a no-op • The recommended pattern is to call ensureInjected() in the static initializer of your various widget types

  5. Image Sprites 1 2 3

  6. public static final Resources INSTANCE = GWT.create(MycssResources.class); 4 MycssResources.INSTANCE.css().ensureInjected(); 5 GWTWidgetsXXX.addStyleName(Resources.INSTANCE.methodOfRes().cssClass()); myButton.addStyleName(Resources.INSTANCE.css().classInmy.css ());

  7. Using an external resource The "with" element declares a field holding a resource object whose methods can be called to fill in attribute values. In this case it will be instantiated via a call toGWT.create(Resources.class).

More Related