<code>
response.render(CssHeaderItem.forReference(reference));
</code>

created a css link like this:
<link rel="stylesheet" type="text/css" 
href="../../resources/portal/css/portal.css" />

What i've tried to get is this:
<link rel="stylesheet" type="text/css" href="/resources/trauer/css/portal.css" 
/>

We have all our css in an external folder (apache DOC_ROOT static). So this url 
is required.

But now i'm in doubt that i've misused the ResRef and HeaderItem concepts.
It seems to be more natural to extend the CssUrlHeaderItem and provide the 
dependencies there instead of connecting this to the ResourceReference and 
delegate the call. Maybe that is cause of how this is implemented.

Thanks
Per

-------- Original-Nachricht --------
> Datum: Tue, 6 Nov 2012 10:15:11 +0200
> Von: Martin Grigorov <[email protected]>
> An: [email protected]
> Betreff: Re: Why can\'t CssUrlReferenceHeaderItem have dependencies?

> Hi,
> 
> Why do you use  reference.getUrl() to create CssUrlReferenceHeaderItem ?
> Why not just : response.render(CssHeaderItem.forReference(reference));
> 
> CssUrlReferenceHeaderItem by itself works with plain Url and there is no
> way how Wicket can know that it may depend on some other dependencies.
> 
> 
> 
> On Tue, Nov 6, 2012 at 10:02 AM, Per Newgro <[email protected]> wrote:
> 
> > Hi Martin,
> >
> > i use the UrlResRef like the "normal" ResRef. A specialiced css is
> > depending
> > on a base css.
> > This base css should be guaranteed on special css usage.
> >
> > public class PortalCssDependingResourceReference extends
> > UrlResourceReference {
> >
> >     private final String portalId;
> >
> >     public PortalCssDependingResourceReference(String resourceUrl,
> String
> > portalId) {
> >         super(Url.parse(resourceUrl));
> >         this.portalId = portalId;
> >     }
> >
> >     protected final String getPortalId() {
> >         return portalId;
> >     }
> >
> >     @Override
> >     public Iterable<? extends HeaderItem> getDependencies() {
> >         ArrayList<HeaderItem> dependencies = new
> ArrayList<HeaderItem>();
> >         for (HeaderItem headerItem : super.getDependencies()) {
> >             dependencies.add(headerItem);
> >         }
> >         dependencies.add(CssHeaderItem.forReference(new
> > PortalCssResourceReference(this.portalId)));
> >         return dependencies;
> >     }
> >
> >     @Override
> >     public boolean isContextRelative() {
> >         return true;
> >     }
> > }
> >
> > It is included as expected with this (sample) code in my page. And this
> is
> > the cause why i'm wondering this is not implemented.
> >
> >     @Override
> >     public void renderHead(IHeaderResponse response) {
> >         final PortalCssDependingResourceReference reference = new
> > PortalCssDependingResourceReference("resources/special.css",
> > getPortalId());
> >         response.render(new
> > CssUrlReferenceHeaderItem(reference.getUrl().toString(), null, null) {
> >
> >             @Override
> >             public Iterable<? extends HeaderItem> getDependencies()
> >             {
> >                 return reference.getDependencies();
> >             }
> >         });
> >         super.renderHead(response);
> >     }
> >
> > I hope this is answering your question.
> > Thanks
> > Per
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
> 
> 
> -- 
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to