How to change css value's through CssResource mechanism?

39 views
Skip to first unread message

Ed

unread,
Nov 10, 2011, 4:49:52 PM11/10/11
to Google Web Toolkit
I have a FlexButton widget and want to change the width, that is
defined in the css file, in a flexible way.
FlexButton uses ClientBundle and CssResource.

I looked at the @eval and value() functions but don't think they help
me.
@eval references to a static function such that it results in a value
for all FlexButton instances, while I want to have different width for
different instances.

I hoped to pass in a Preferences instances that contains the width
that is then used in the css file, but I don't see how I get this to
work.

Please some advice on how best to do this?
-Ed

Thomas Broyer

unread,
Nov 10, 2011, 5:47:12 PM11/10/11
to google-we...@googlegroups.com
You'll have to either define specific CSS classes with different widths, or use button.getElement().getStyle().setWidth(newWidth, Unit.PX);

Ed

unread,
Nov 11, 2011, 3:12:19 AM11/11/11
to Google Web Toolkit
Yes, I was afraid of that.
I hoped to do it more elegant and be able to use preferences per
Widget instance.
It's however only possible to use preferences per Widget type
(globally).

Is it even possible per instance, such that would it be worth adding
an issue about this?

Uemit

unread,
Nov 11, 2011, 8:19:27 AM11/11/11
to google-we...@googlegroups.com
If the FlexButton uses ClientBundle and CssResources you should be able to override it on instance level. 
Similar to how you can do it with the CellWidget where you can pass a different CssResource implementation in the constructor. However this requires that you somehow have access to the ClientBundle/CssResource file of your FlexButton


Ed Bras

unread,
Nov 11, 2011, 10:34:26 AM11/11/11
to google-we...@googlegroups.com
@Uemit,
Thanks for input but that's not the question.

I use this mechanism in many places, combined with @Import, and that is the reason of my question as you don't want to override the style/resources for every time you need a button with just different preferences.
It would be nice to specify preferences on an instance base.

On Fri, Nov 11, 2011 at 2:19 PM, Uemit <uemit...@gmail.com> wrote:
If the FlexButton uses ClientBundle and CssResources you should be able to override it on instance level. 
Similar to how you can do it with the CellWidget where you can pass a different CssResource implementation in the constructor. However this requires that you somehow have access to the ClientBundle/CssResource file of your FlexButton


--
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/-/BnOF8UAQm44J.
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