I am trying to do the same thing. However it does not seem to work.
In my setup I have multiple modules. One module has an entry point and other
modules do not. I try to load css in the module that does not have an entry
point. The css is located in war/ directory.

I get Warning 404 in the console. Not sure what's happening here.

Thanks

On Thu, Jul 23, 2009 at 9:23 PM, Rick <rick4...@gmail.com> wrote:

>
> Hi Adam
>
> Thanks a lot. Its working fine now.
>
> On Jul 24, 2:50 am, Adam T <adam.t...@gmail.com> 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 <rick4...@gmail.com> 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 Google-Web-Toolkit@googlegroups.com
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/Google-Web-Toolkit?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to