PDA

View Full Version : Styling/Sizing: GXT vs CSS - ideas on when to use what



googelybear
11 Sep 2009, 3:37 PM
When using gxt/gwt I'm always uncertain how much of the styling/sizing should be put in css and how much in (java) code.
Example: The width of an object can be set in css and via component.setWidth in code. Generally I think putting as much visual aspects (borders, padding, colors, fonts etc.) in css as possible is a good practice (having it all in one place and not cluttered around in the source) but with gxt/gwt I'm not sure anymore, because I don't want to prevent any kind of optimizations that the framework could do for me if I specify it in code.
For instance one of the goals of gwt is to hide the browser differences and unify programming (you don't need to care about which browser the user is running) - instead the adaptation to the individual browsers is performed by gxt/gwt. Example: When I set the size of an element in css I have to keep in mind the the size is calculated differently in IE (the size is the total size including padding, borders etc.) and in Firefox (the size does NOT include padding/margin).
I ended up using a split approach - having some of the styling/sizing in css and some of it in code - especially when using complex nested layouts I specify the sizes in code, as explained by sven here (http://www.extjs.com/forum/showthread.php?p=369267#post369267):

If you have boxcomponents you should always size them with boxComponent.setSize.

Some boxcomponents are very complex and also needs to resize childrens


How do you usually do it in your applications? Do you have any suggestions/experiences?

googelybear
18 Sep 2009, 11:12 AM
hmm...I'm surprised that nobody answered so far to this topic ;-)
This means that either a) nobody knows how to do this properly or b) it's totally obvious.
In case of b) can someone please point me into the right direction? thx!
In case of a) it would be nice if someone from the gxt dev team could give some general guidelines/rules as this is quite important to get the max out of gxt (and prevent any incompatibilities) and I think a lot of people would profit from this knowledge (this could also be added to the help section).

Arno.Nyhm
21 Sep 2009, 7:03 AM
general things i put in css (if it is possible)
things to layout a single item i do with setWidth etc.