How to add custom styles to custom cells

163 views
Skip to first unread message

Shaun Tarves

unread,
Mar 6, 2012, 11:10:41 AM3/6/12
to google-we...@googlegroups.com
Hi -

I have a custom cell definition that I want to add a custom style definition (.quiet) for. In this case, it's a cell that goes into a cell table. What I have done (and is NOT working) is the following:

interface CellTableResources extends CellTable.Resources {

@Source({CellTable.Style.DEFAULT_CSS, "DesktopServiceTable.css"})

CellTableStyle cellTableStyle();

}

interface CellTableStyle extends CellTable.Style {

String quiet();

}

I added a .quiet{} rule to my DesktopServiceTable.css

Then, the render() method of my cell class uses the "quiet" class: @SafeHtmlTemplates.Template("<strong>{0}</strong><br/><em class=\"quiet\">Updated: {1}</em>")

The class name is on the em element in the DOM (within the td of the table), but there is no style associated with it - it's almost like it wasn't "injected" or something.


Any ideas?

Jens

unread,
Mar 6, 2012, 11:49:46 AM3/6/12
to google-we...@googlegroups.com
As soon as you use ClientBundle with CssResource all css classes defined by a CssResource are obfuscated (unless you disable it in your gwt.xml file). That means something like ".SXYDSS" is injected in your website but you have hardcoded "quite" in your cell. Obviously this wont work.

So you have to call CellTableStyle.quiet() and put the output (the method returns the obfuscated class name) into the class attribute of <em>. As SafeHtmlTemplates are defined through annotations and you cant access CssResource methods in a static way you have to make your class attribute value a method parameter [and you probably have to use SafeStyles (see SafeStyleUtils and SafeStyleBuilder)], e.g.

@SafeHtmlTemplate(....<em class=\"{2}\"> ....)
SafeHtml template(SafeHtml first, SafeHtml second, String cssClass);

or if GWT complains because of a variable as class attribute value:

@SafeHtmlTemplate(....<em class=\"{2}\"> ....)
SafeHtml template(SafeHtml first, SafeHtml second, SafeStyles cssClass);


-- J.

Shaun Tarves

unread,
Mar 6, 2012, 12:30:04 PM3/6/12
to google-we...@googlegroups.com
Hi Jens -

Completely overlooked that. Your solution worked correctly with the String/class name approach. Thanks!

- Shaun

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/FnQpCwkjLH0J.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Reply all
Reply to author
Forward
0 new messages