| Author |
css problem with portlets
|
|
|
| Hi,
I have used following way to include css file in portlet pages.
<link href="<%= renderResponse.encodeURL(renderRequest.getContextPath()+"/css/sb_styles.css")%>" rel="stylesheet" type="text/css">
But its not working. Is this any other way need to include css. pls help me.
| |
|
| You should use single quotes for encode url...
i.e.
<link href='<%= renderResponse.encodeURL(renderRequest.getContextPath()+"/css/sb_styles.css")%>' rel="stylesheet" type="text/css">
Try this and let me know
| |
|
| I tried the same, but no use.
| |
| Michael Harris 2007-07-25, 1:23 pm |
| First note that your code will result in HTML that will not validate
since you have a <link> tag outside the <head> tag. The proper way to
include CSS is to link the stylesheet in the <head> tag in the theme.
Having said this, most browsers will honor <link> outside the <head>
even though it is invalid so you should still be able to do this.
The code you posted looks correct assuming that your css file is located
at /css/sb_styles.css in your war.
First thing to do is be sure that the file is actually getting served
up. Open your portlet, do a "view source" and search for your link tag.
Copy the URL out of the href attribute and paste it into the browser
address bar. Add on the front of the URL the
http://yourservername:portname part before the /wps part you copied. If
you get the CSS contents, then your file is serving correctly... but it
is either being ignored because of some other error on your page OR the
styles in it are not formatted correctly. If you do not get the CSS
contents and get something like a 404 error, then you either have
explicitly turned off file serving in your portlet (which isn't likely)
or the file path is wrong somehow. Can you serve images from your war
into <img> tags in your portlet? The CSS url should be generated
exactly the same way.
Note: You can't serve up images or CSS from underneath the WEB-INF
folder. If the browser needs access to call and load the files directly
without going through the portlet, then the files must be outside WEB-INF.
| |
|
| I called my css file in head.jspf after that it worked fine. thanx for yr suggestion.
|
|
|
|