Of course you need to do: stocksFlexTable.addStyleName("stocksFlexTable ") .You seem to be completely missing the point that the variable stocksFlexTable is not the name of the HTML element. I think you need to review what an HTML page looks like. This is the pseudocode GWT will generate when it compiles your code: <script> var stocksFlexTable = HTML.createDiv(); DOM.insert(stocksFlexTable); </script> So please explain to me how it would be meaningful in any way to apply a style to a Javascript variable name? On Thu, Mar 19, 2009 at 8:15 PM, Coonay <[email protected]> wrote: > > public class FirstGWT implements EntryPoint { > private FlexTable stocksFlexTable = new FlexTable(); > } > > FirstGWT.css: > . stocksFlexTable { > border:solid; > } > > if i want to apply the stocksFlexTabl style, > do i have to call > stocksFlexTable.addStyleName("stocksFlexTable ") or something else gwt > api interface, > if yes ,i think gwt mix the content with style. > > what i expect is that GWT will apply style to the elment using css > style selector with the same name as element name,gwt user need not to > call addStyleName explicitly(make this just a optional ) > > > > > > > On Mar 20, 2:51 am, Vitali Lovich <[email protected]> wrote: > > Do not do it that way. Style's should always be in a separate CSS > document > > - it's better that way any way you look at it. > > > > GWT is not mixing content with style I don't think. How you would write > the > > equivalent HTML? > > > > <table class="stocksFlexTable"> </table> (that's not the element > FlexTable > > uses, but this is for demonstration purposes only). > > > > If you don't specify the class, how is the CSS supposed to realize which > > particular table you wanted to style? The variable name is just a > > javascript variable - has absolutely no relation to CSS. > > > > The addStyleName simply modifies the class attribute (so that you can > style > > it with CSS as you want). If you don't like that, you could always do > > getElement().setId("") (but remember that id uniquely identifies an > element) > > > > AFAIK, mixing content with style is a different problem where, for > instance, > > elements in HTML used to represent both the visual style & the document > > structure. > > > > Am I completely wrong? > > > > On Thu, Mar 19, 2009 at 2:16 PM, Danny Schimke <[email protected] > >wrote: > > > > > You could do something like this: > > > > > Style style = tmpElement.getElement().getStyle(); > > > style.setProperty("border", "1py solid #000000;"); > > > > > -Danny > > > > > 2009/3/19 Coonay <[email protected]> > > > > >> like old html,gwt mix content with style again? > > >> in gwt ,most dynamic UI element have to set style with addStyleName > > >> method? > > >> such as the following, > > >> public class FirstGWT implements EntryPoint { > > >> private FlexTable stocksFlexTable = new FlexTable(); > > >> } > > > > >> if i define the style in the css > > >> . stocksFlexTable { > > >> } > > > > >> can gwt apply this to stocksFlexTable automatically without manually > > >> calling addStyleName? > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
