You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Per Newgro <pe...@gmx.ch> on 2012/11/05 16:38:49 UTC

Why can't CssUrlReferenceHeaderItem have dependencies?

Hi,

i was wondering why CssUrlReferenceHeaderItem (wicket 6.2.0) is implemented by HeaderItem#getDependencies() which returns an empty list.
The CssReferenceHeaderItem has a getDependencies implementation
which uses the dependencies provided by the resource reference.

If i extend CssUrlReferenceHeaderItem (for testing) and provide the dependencies of the resource reference (analogoues to CssReferenceHeaderItem) everything works fine.

But maybe i miss here something. So my question is: Is it required that CssUrlReferenceHeaderItem is not handling dependencies of the resource reference?

Thanks for explanation.
Per

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Why can't CssUrlReferenceHeaderItem have dependencies?

Posted by Per Newgro <pe...@gmx.ch>.
<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 <mg...@apache.org>
> An: users@wicket.apache.org
> 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 <pe...@gmx.ch> 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: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> 
> 
> -- 
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Why can't CssUrlReferenceHeaderItem have dependencies?

Posted by Martin Grigorov <mg...@apache.org>.
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 <pe...@gmx.ch> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: Why can't CssUrlReferenceHeaderItem have dependencies?

Posted by Per Newgro <pe...@gmx.ch>.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Why can't CssUrlReferenceHeaderItem have dependencies?

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Mon, Nov 5, 2012 at 5:38 PM, Per Newgro <pe...@gmx.ch> wrote:

> Hi,
>
> i was wondering why CssUrlReferenceHeaderItem (wicket 6.2.0) is
> implemented by HeaderItem#getDependencies() which returns an empty list.
> The CssReferenceHeaderItem has a getDependencies implementation
> which uses the dependencies provided by the resource reference.
>
> If i extend CssUrlReferenceHeaderItem (for testing) and provide the
> dependencies of the resource reference (analogoues to
> CssReferenceHeaderItem) everything works fine.
>

CssUrlReferenceHeaderItem works with a Url which  doesn't provide
#getDependencies().
What ResourceReference do you use in your version of
CssUrlReferenceHeaderItem ?



>
> But maybe i miss here something. So my question is: Is it required that
> CssUrlReferenceHeaderItem is not handling dependencies of the resource
> reference?
>
> Thanks for explanation.
> Per
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>