Raul
Raul

Reputation: 179

Location of css file in a GWT project

I have css file named Sample.css which contain the below contents.

         .bandit-report{
       margin-left: 20px;
          }
         .bandit-report1{
         margin-left: 50px;
          }

I have the ABCD.gwt.xml where I have made the below entry for the css file

    <stylesheet src='Sample.css' />

I set the style name using setStyleName(String) method. However the margin-left changes are not getting reflected. I dont know where to place the Sample.css file. I have currently place both ABCD.gwt.xml and Sample.css in the same directory.

Kindly Help.

Upvotes: 1

Views: 1127

Answers (4)

Marconius
Marconius

Reputation: 713

You should create a folder named public in the same place where your client, server and shared folders are and put it in there, that's the default location it will look.

Upvotes: 0

Thomas Broyer
Thomas Broyer

Reputation: 64541

Relative paths in <stylesheet> in a gwt.xml files are relative to the "module base URL" (returned by GWT.getModuleBaseURL() on the client-side code; this is the folder into which GWT will generate the nocache.js file and everything else). Having a file output in this directory is as easy as putting it in your public path, which by default is a public subfolder of your GWT module (next to your client subpackage). It's worth noting that public paths are inherited from modules you <inherit>; this is how GWT's built-in themes work.

If you put your stylesheet in your war folder, then you shouldn't inject it from your gwt.xml, you should rather load it with a <link rel=stylesheet> in your HTML host page.

Upvotes: 4

Raul
Raul

Reputation: 179

I changed the entry made in ABCD.gwt.xml to as below. Now its working.

     <stylesheet src='/Sample.css' />

Upvotes: 1

user1633525
user1633525

Reputation:

Use your browser developer panel to find out the location of css file.

Upvotes: 0

Related Questions