To start, don't use a Label to contribute css.  Use a header contributor.
That's what they're made for.
On 2011 7 19 13:22, "Loren Cole" <[email protected]> wrote:
> We're making our application skinable, but I'm having some trouble getting
> user specified css into the right place in the header. We're working in a
> distributed environment, so instead of saving their css in the file system
> we're putting it in our database, and in order to get the cascade to work
> properly we need to add this css after all the others. Here's how I'm
> adding it:
>
> StandardPage.java
>
> onInitialize()
> //Add any override style
> Tenant tenant = MyWebSession.get().getTenant();
> Css css = cssRepository.GetStyleByTenant(tenant);
> if(tenant.getBranding() && css != null) {
> add(new Label("style", css.getStyle()));
> }
> }
>
> StandardPage.html
>
> <wicket:head>
> <style type="text/css" wicket:id="style"></style>
> </wicket:head>
>
> -----------------------------------------
> So the issue is that thet style tag comes before all my header
> contributions. I've tried specifying a header response decorator like so:
>
> Application.java
>
> public static final String HEADER_FILTER_NAME = "myHeaderBucket";
>
> init() {
> super.init();
> setHeaderResponseDecorator(new IHeaderResponseDecorator() {
>
> HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter[]
> filters = {new CssAcceptingHeaderResponseFilter(HEADER_FILTER_NAME)};
> @Override
> public IHeaderResponse decorate(IHeaderResponse response) {
> return new
> HeaderResponseContainerFilteringHeaderResponse(response,
HEADER_FILTER_NAME,
> filters);
> }
> });
> }
>
> StandardPage.html
>
> <wicket:head>
> <div wicket:id="myHeaderBucket"></div>
> <style type="text/css" wicket:id="style"></style>
> </wicket:head>
>
> ------------------------------
>
> Unfortunately I'm getting this exception when I instantiate a page:
>
> 12:28:04,097 INFO [STDOUT] 2011-07-19 12:28:04.096 [http-127.0.0.1-8080-1]
> [127.0.0.1] [T:2] [U:3 - joe_sharp]
> [com.transverse.bleep.wicket.desktop.DesktopPage] ERROR
> org.apache.wicket.RequestCycle 1529 - Exception in rendering component:
> [MarkupContainer [Component id = headerBucket]]
> org.apache.wicket.WicketRuntimeException: Exception in rendering
component:
> [MarkupContainer [Component id = headerBucket]]
> at org.apache.wicket.Component.renderComponent(Component.java:2729)
> ~[wicket-1.4.17.jar:1.4.17]
> at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
> ~[wicket-1.4.17.jar:1.4.17]
> at org.apache.wicket.Component.render(Component.java:2521)
> ~[wicket-1.4.17.jar:1.4.17]
> ...
> Caused by: java.lang.RuntimeException: there was an error processing the
> header response - you tried to render a bucket of response from
> HeaderResponseContainerFilteringHeaderResponse, but it had not yet run and
> been closed. this should occur when the header container that is standard
> in wicket renders, so perhaps you have done something to keep that from
> rendering?
> at
>
org.apache.wicket.resource.filtering.HeaderResponseFilteredResponseContainer.onComponentTagBody(HeaderResponseFilteredResponseContainer.java:67)
> ~[wicket-1.4.17.jar:1.4.17]
> at org.apache.wicket.Component.renderComponent(Component.java:2690)
> ~[wicket-1.4.17.jar:1.4.17]
> ... 81 common frames omitted
>
>
> Any ideas on what I'm doing wrong? Is there an easier approach I can take?
>
> Thanks,
> Loren

Reply via email to