THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Panel |
---|
<link wicket:id="mycss" rel="Stylesheet" type="text/css" href="styles/main.css"/> |
In your java:
Code Block | |
---|---|
Panel | |
Wiki Markup |
import wicket.markup.html.WebComponent;
import wicket.model.IModel;
import wicket.model.Model;
import wicket.AttributeModifier;
import wicket.Component;
...
WebComponent c = new WebComponent( "mycss" );
IModel model = new Model()
{
public Object getObject( Component c )
{
if ( someConditionIsTrue )
return "stylesheetx.css";
else
return "stylesheety.css";
}
};
c.add( new AttributeModifier( "href", model ) );
add( c );
|
A word of caution about the <body> tag
...
and this in your Page Java file for Wicket 1.1:
Panelcode |
---|
WebMarkupContainer pageCSS = new WebMarkupContainer("pageCSS"); add(pageCSS); PackageResourceReference pageCSSResource = new PackageResourceReference(getClass(), "css/page.css"); pageCSS.add(new AttributeModifier("href", false, new Model(urlFor(pageCSSResource.getPath())))); |
or this for Wicket 1.2:
Panelcode |
---|
add(new StyleSheetReference("pageCSS", getClass(), "css/page.css")); |