Hi Adam Thanks a lot. Its working fine now.
On Jul 24, 2:50 am, Adam T <[email protected]> wrote: > Hi Rick, > > The last line in your native method should read: > > $doc.getElementsByTagName("head")[0].appendChild(fileref); > > As GWT uses $doc to refer to the pages document. > See:http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html#D... > > //Adam > > On 23 Juli, 15:03, Rick <[email protected]> wrote: > > > Hi All > > > I am building an application using GWT 1.6. In my application I need > > to load external stylesheet at runtime. But its not working. I am able > > to load stylesheet in an independent html file. But when I am using > > same with GWT, its not reflecting. Below is a sample code to produce > > this case. Any help/suggestion will be highly appriciated. > > > StyleSheetEntryPoint.java > > > package com.example.foo.client; > > import com.google.gwt.core.client.EntryPoint; > > import com.google.gwt.user.client.ui.HTML; > > import com.google.gwt.user.client.ui.RootPanel; > > > public class StyleSheetEntryPoint implements EntryPoint { > > > public void onModuleLoad() { > > loadStyleSheet(); > > HTML html = new HTML("Hello"); > > html.setStyleName("sendButton"); > > RootPanel.get().add(html); > > } > > > public static native void loadStyleSheet()/*-{ > > var fileref=document.createElement("link"); > > fileref.setAttribute("rel", "stylesheet"); > > fileref.setAttribute("type", "text/css"); > > fileref.setAttribute("href", "Component.css"); > > > > document.getElementsByTagName("head")[0].appendChild(fileref); > > }-*/; > > > } > > > Component.css > > .sendButton {font-weight:bold;font-size: 16pt;} > > > Following HTML is giving me expected behaviour. > > <html> > > <head> > > <script type="text/javascript"> > > function loadCSS(){ > > var fileref=document.createElement("link"); > > fileref.setAttribute("rel", "stylesheet"); > > fileref.setAttribute("type", "text/css"); > > fileref.setAttribute("href", "Component.css"); > > document.getElementsByTagName("head")[0].appendChild(fileref);} > > > </script> > > </head> > > <body onload="loadCSS()"> > > <DIV class="sendButton">Hello</DIV> > > </body> > > </html> > > > Thanks and regards > > > Rick --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
