I have an element in GWT. I want it to float right. I have tried DOM.setStyleAttribute(element, "float", "right");
but is not working. I am not sure if I am using correct attribute (float). Do you have any idea?
-
Can you post some code snippets to demonstrate what you're trying to do exactly?– Jack LeowJul 9, 2009 at 12:21
3 Answers
The correct way to float is with "cssFloat" property:
DOM.setStyleAttribute(element, "cssFloat", "right");
"float" is a reserved keyword in javascript.
-
1Thanks for this! I just wasted 2hrs of my life trying to get this to work. What puzzles me though... this is a style attribute name. Why does GWT need to use 'cssFloat' and not just 'float'. There should be no confusion between the 'float' style property and any reserved words in Javascript. May 1, 2012 at 0:31
Ok this begs the obvious question... why aren't you using GWT layout to do this? That's kinda the point of GWT is to (at least in part) abstract CSS positioning/layout. Or, rather, to use the more familiar desktop GUI layout models (BoxLayout, GridLayout and so forth).
-
This question I asked raised from need.Every layout you use in gwt results in table(there are few exception) .And if in a view you render many tables it takes a long time in IE.So using float I wanted to haave a two column looks of a table . Feb 23, 2009 at 10:02
-
yes, round peg, square hole, but that also begs the question, why isnt GWT more flexible in this regard? or why is gwt wigets internally use floats/css/divs to position and layout, instead of using tables? Dont get me wrong, i am a fan of gwt, but lately i m seeing its limitations.– ChiiFeb 23, 2009 at 12:40
-
Because GWT is representing complex layout through a cross-browser abstraction model and the only way to do complex layout with things like vertical centering is, like it or not, with tables. If you're not buying into the "GWT way" you're using the wrong technology.– cletusFeb 23, 2009 at 12:43
-
I like GWT but at a time you have to do work around to accomodate changes Feb 24, 2009 at 3:32
My thought here would be that you solve this in a static XHTML and CSS file approach. Then once you have it working there, you can transpose that into a gwt approach.
With the GWT approach I would still promote the philosophy of styling and presentation remain in the CSS file, static structure remains in the host HTML file, and dynamic widget placement occurs in the GWT code.
Worth reminding (or mentioning) that as you layout these DIVs and SPANs to use ids, to help you locate that element within your GWT code and populate it with your dynamic controls. Of course, the use of "class" in the element definitions to improve the CSS you will use to perform the float.