PDA

View Full Version : How to call CSS file



sundhar_v
13 Aug 2009, 5:14 PM
HI all,

I am using my own css apart from ext-all.css. If i am keeping the css file in the public folder and include the syntax in xml (<stylesheet src="demo.css" />) file i am getting the class in the result page. where as if keep the style in a folder means i am not getting the css class in the result page. can anyone help me how to achieve this task. Because keeping css in every public folder is not advisable. it should be in one folder so that we can add the class. Pl. clarify on this.

Thanks and Regards,
Sundhar

Arno.Nyhm
14 Aug 2009, 8:24 AM
what you mean with "every public folder"?
why it should not in the place where is your calling page (like welcomeGWT.html or similar stuff)?

or mabye you need to clarify your question.

PS: maybe you can also use not a relativ ( src="demo.css" ) but a absolute path ( src="/mypath/demo.css" ) to your css...

sundhar_v
14 Aug 2009, 4:40 PM
Thank you for your below suggestion, i have tried that also. it is not working. My idea is i want to keep the CSS in a separate folder within the project and include the path in the xml file means it should work. But now it is not working i need to copy the css file in each and ever public folder then only it is recognising the css. Please have a look on my folder sturcture. I have also provided my result page.

I have written a class file like below and i have called the same in my java file like


LabelField lblMsg = new LabelField();
lblMsg.setText("Your Request youf change of Password has been accepted and we will get back to you within 24 hours.");
lblMsg.setStyleName("tcHeading");


.tcHeading

{
font-size:12px;
font-weight:bold;
color:#ff0000;
margin-bottom:5x;
text-align:center;
float:left;
)

In the Xml file i have included the stylesheet like this

<stylesheetsrc="/CSSTest/demo.css"/>

The text shold display in Red color. But it not coming. If i keep the stylesheet in public folder i am getting the result properly. But i want to call the css in a folder. pl. help me to acheive the task. if you need any further clarification. pl write to me, i will provide the same.
Thanks and Regards,
sundhar

daddieke
15 Aug 2009, 1:47 AM
I have my .css files in a separate folder in the war - directory and refer to them in the main html page.

Structure is something like this :
war - demo.html
..... - css - gxt-all.css
............. - demo.css

In demo.html head section put :
<link type="text/css" rel="stylesheet" href="css/gxt-all.css">
<link type="text/css" rel="stylesheet" href="css/demo.css">

Works for me, hope it does for you ...
Wouter

sundhar_v
15 Aug 2009, 5:34 AM
sorry yar i have tried this method already, but i am not getting the proper result rather i am getting the below warning

[WARN] Resource not found: CssTest/demo.css; (could a file be missing from the public path or a <servlet> tag misconfigured in module myForm.Myfrom.gwt.xml ?)

As per your below info i have included the css file in the html file like this


<linkrel="stylesheet"type="text/css"href="css/ext-all.css"/>
<linktype="text/css"rel="stylesheet"href="CssTest/demo.css"/>

Pl. let me know where to create CSSTest folder.

I have forwarded my folder sturcture. Kindly have a look on the same and advise me.

Thanks and Regards,
Sundhgar

daddieke
16 Aug 2009, 12:43 AM
You have the CssTest folder in the source structure.
It should be in the war folder, at least if you're using GWT >= 1.6
I'm not familiar with Eclipse but I suppose you'll find war under WebContent in your project tree

sundhar_v
16 Aug 2009, 9:18 PM
I have moved the cssTest folder to WebContent folder But i it is not working. For your quick understanding, i am forwarding my project itself. Pl. have a look on the war file and do the needful.

Thanks and Regards,
Sundhar

Arno.Nyhm
19 Aug 2009, 12:51 AM
1st) place it at this folder where your demo.html is. and then use <linktype="text/css"rel="stylesheet"href="demo.css"/>

2nd) take the generated war file and inspect the structure. there you see where your css are placed. and you see which path you need to set to the css file.