how to import a css file in module.gwt.xml

1,396 views
Skip to first unread message

wahaha

unread,
Sep 14, 2011, 2:23:42 AM9/14/11
to Google Web Toolkit
i use gwt v2.3.
if i write a tag <link>,it wrong:
[ERROR] Line 22: Unexpected element 'link'
[ERROR] Failure while parsing XML
com.google.gwt.core.ext.UnableToCompleteException: (see previous log
entries)


if i change to a tag <stylesheet>,then i do not work.

Palo G.

unread,
Sep 14, 2011, 10:13:19 AM9/14/11
to Google Web Toolkit
The tag <link> is not declared in gwt DND. There are many ways how to
append styles into GWT application, see
http://code.google.com/intl/cs/webtoolkit/doc/latest/DevGuideUiCss.html

- you can use link tag in your html file where you are appending gwt
js
- with UI Binder
- in module file *.gwt.xml , use <stylesheet src="css-url" /> (if the
name of css file contains non alphanumeric letters then this can cause
problems sometimes)
- use CssResource interface

Sudhakar Abraham

unread,
Sep 14, 2011, 11:30:17 AM9/14/11
to Google Web Toolkit
There are three ways to include css file.

1. you can add a link tag inside the <head> section of the host page
( you also need to create a file called your_Stylesheet.css in the
public directory ).

Ex:
<link type="text/css" rel="stylesheet" href="your_StyleSheet.css" />

2. you can include css on project.gwt.xml file.

Ex:
<stylesheet src='Your_StyleSheet.css' />

3. Using UI binder, specify the <ui:style> ... </ui:style>

Ex:
<ui:style>
.buttonSave {
float: left;
margin-top: 10px;
margin-left: 10px;
margin-bottom: 10px;
}
</ui:style>

S. Abraham
www.DataStoreGwt.com
Reply all
Reply to author
Forward
0 new messages