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/>

Reply via email to