You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Bertrand Guay-Paquet <be...@step.polymtl.ca> on 2012/02/03 16:40:30 UTC

ResourceReference for resource in webapp dir

Hi,

I have the following code in my base page:

public void renderHead(IHeaderResponse response) {
     // scripts/jquery-1.7.1.min.js is in webapp dir
     response.renderJavaScriptReference("scripts/jquery-1.7.1.min.js");
}

How can I transform this direct URL to a ResourceReference?

PackageResourceReference is not a good fit because I don't want to store 
the .js in a Java package since it is used by non-wicket pages.

With ContextRelativeResource, Wicket reads the actual resource and sends 
the result instead of simply pointing to a URL.

AbstractResource with its newResourceResponse() abstract method requires 
to return the actual ResourceResponse which won't allow for a simple URL.

So from what I gather, I would have to fallback to implementing an 
IResource's respond(Attributes attributes) method. I looked at the 
implementation in AbstractResource but I'm confused about what to do 
with headers since I only want a URL.

So, does this functionality already exist? If not, do you have a few 
pointers to steer me in the right direction?

Thanks,
Bertrand

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


Re: ResourceReference for resource in webapp dir

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

I recommend you to read again the article.
See below some improvements:

On Wed, Feb 8, 2012 at 7:33 PM, Kayode Odeyemi <dr...@gmail.com> wrote:
> On Wed, Feb 8, 2012 at 3:58 PM, Martin Grigorov <mg...@apache.org>wrote:
>
>> Hi,
>>
>> Everything is possible.
>> See http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/
>> You the request parameter to map to your real resource and load it.
>>
>> Thanks.
>
> I have all the classes in place now. Could you help with some pointers as
> to how to use this in a Page component renderHead? I'm working with
> something like this:
>
> private static final UrlResourceReference DASHBOARD_JS = new
> UrlResourceReference(
>            "/WEB-INF/js/dashboard.js");

Remove that completely ^^

>
> @Override
>    public void renderHead(IHeaderResponse response) {
>        response.renderJavaScriptReference(DASHBOARD_JS);

Here use the url generation approach with #urlFor(new
UrlResourceReference(), new PageParameters().add("dashboard.js"));
This adds indexed parameter.

>    }
>
> Application.java
> ----------------------
> super.mountResource("/WEB-INF/js/dashboard.js", new UrlResourceReference());

mountResource("/Dashboard/js", new UrlResourceReference());

>
> ContextRelativeURLResource.java
> -------------------------------------------------
> @Override
>    protected ResourceResponse newResourceResponse(Attributes attributes) {

attributes.getPageParameters.get(0) will return you "dashboard.js".
Load it with ServletContext.getResource() and with the WriteCallback
write its bytes into attributes.getResponse().

>        final ResourceResponse resourceResponse = new ResourceResponse();
>
>        if (resourceResponse.dataNeedsToBeWritten(attributes)) {
>
>            final UrlContextResourceStream urlContextResourceStream = new
> UrlContextResourceStream(path);
>
>  resourceResponse.setContentType(urlContextResourceStream.getContentType());
>
>  resourceResponse.setLastModified(urlContextResourceStream.lastModifiedTime());
>            resourceResponse.setFileName(path);
>            resourceResponse.setWriteCallback(new WriteCallback() {
>
>                @Override
>                public void writeData(Attributes attributes) {
>                    URL url = null;
>                    try {
>                        url = urlContextResourceStream.getResourceURL(); //
> getURL uses path passed into UrlResourceStream
>                    } catch (MalformedURLException ex) {
>
>                        throw new WicketRuntimeException(ex);
>                    }
>                }
>            });
>        }
>        return resourceResponse;
>    }
>
> UrlResourceReference.java
> ---------------------------------------
> @Override
>    public IResource getResource() {
>        return new ContextRelativeURLResource(getName());
>
>    }
>
> I'm still getting this in the logs:
> /w/wicket/resource/org.apache.wicket.Application/WEB-INF/js/dashboard-ver-1328653530609.js
>
> Thank you.
>
>  On Wed, Feb 8, 2012 at 5:30 PM, Kayode Odeyemi <dr...@gmail.com> wrote:
>> > On Mon, Feb 6, 2012 at 3:08 PM, Martin Grigorov <mgrigorov@apache.org
>> >wrote:
>> >
>> >> Hi,
>> >>
>> >> I'd not invest in AbstractResourceDependentResourceReference.
>> >> This has been re-implemented in Wicket 6.0 and this class is no more
>> there.
>> >>
>> >> For your case I can recommend you to take a look at Wro4j.
>> >> With this library you can merge all resources which depend on each
>> >> other at build time. For production you can even minimize them.
>> >>
>> >
>> > Hi Martin,
>> >
>> > Assuming I decide not to use wro4j and I want to stick to using Wickets
>> > iRequestMapper, is it possible for me to achieve a mapping for resources
>> > that I have in webapp dir such as:
>> >
>> > com.company.Dashboard -> /dashboard
>> >
>> > Such that if I have a js file in webapp/js/dashboard.js, I can simply map
>> > it to resolve to /dashboard/js/dashboard.js instead of
>> > /com.company.Dashboard/dashboard.js?
>> >
>> > While digging further into Wicket
>> > ResourceReference/Resourcestream/IRequestMapper/IRequestHandler
>> > architecture, I noticed that ResourceReference is designed such that a
>> > scope always returns Java package as part of the url to the resource.
>> >
>> > Using Resourcereference/IRequestMapper, is it possible for me to achieve
>> > the scenario I described above?
>> >
>> > Thanks
>> >
>> >>
>> >> On Mon, Feb 6, 2012 at 4:51 PM, Bertrand Guay-Paquet
>> >> <be...@step.polymtl.ca> wrote:
>> >> > Hi,
>> >> >
>> >> > Thanks for your reply. I'll try to explain why I require this.
>> >> >
>> >> > I want to use a ResRef to implement dependent resources based on
>> >> > AbstractResourceDependentResourceReference. Essentially, when a
>> resource
>> >> > A.js is added to the response, I want B.js to be also automatically
>> >> added.
>> >> >
>> >> > A.js and B.js are both located in the webapp dir instead of being
>> package
>> >> > resources. This is why I wanted to make a ResRef point to the webapp
>> dir
>> >> > directly.
>> >> >
>> >> > I don't have much experience with Wicket resources so maybe what I
>> >> requested
>> >> > originally is the wrong tool for the task.
>> >> >
>> >> >
>> >> > On 04/02/2012 5:07 AM, Martin Grigorov wrote:
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> I didn't understand why you want to use ResRef but if this is your
>> >> >> requirement then the easiest will be to create your own
>> IRequestMapper
>> >> >> that handles only your own IRequestHandler that works with your
>> ResRef
>> >> >> impl.
>> >> >> IRequestMapper#mapHandler(IRequestHandler) is the one responsible to
>> >> >> create Url when RequestCycle#urlFor() is used.
>> >> >> Also take a look at
>> >> >> org.apache.wicket.util.string.UrlUtils#rewriteToContextRelative()
>> >> >>
>> >> >> On Fri, Feb 3, 2012 at 5:40 PM, Bertrand Guay-Paquet
>> >> >> <be...@step.polymtl.ca>  wrote:
>> >> >>>
>> >> >>> Hi,
>> >> >>>
>> >> >>> I have the following code in my base page:
>> >> >>>
>> >> >>> public void renderHead(IHeaderResponse response) {
>> >> >>>    // scripts/jquery-1.7.1.min.js is in webapp dir
>> >> >>>
>>  response.renderJavaScriptReference("scripts/jquery-1.7.1.min.js");
>> >> >>> }
>> >> >>>
>> >> >>> How can I transform this direct URL to a ResourceReference?
>> >> >>>
>> >> >>> PackageResourceReference is not a good fit because I don't want to
>> >> store
>> >> >>> the
>> >> >>> .js in a Java package since it is used by non-wicket pages.
>> >> >>>
>> >> >>> With ContextRelativeResource, Wicket reads the actual resource and
>> >> sends
>> >> >>> the
>> >> >>> result instead of simply pointing to a URL.
>> >> >>>
>> >> >>> AbstractResource with its newResourceResponse() abstract method
>> >> requires
>> >> >>> to
>> >> >>> return the actual ResourceResponse which won't allow for a simple
>> URL.
>> >> >>>
>> >> >>> So from what I gather, I would have to fallback to implementing an
>> >> >>> IResource's respond(Attributes attributes) method. I looked at the
>> >> >>> implementation in AbstractResource but I'm confused about what to do
>> >> with
>> >> >>> headers since I only want a URL.
>> >> >>>
>> >> >>> So, does this functionality already exist? If not, do you have a few
>> >> >>> pointers to steer me in the right direction?
>> >> >>>
>> >> >>> Thanks,
>> >> >>> Bertrand
>> >> >>>
>> >> >>>
>> ---------------------------------------------------------------------
>> >> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> >>> For additional commands, e-mail: users-help@wicket.apache.org
>> >> >>>
>> >> >>
>> >> >>
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > 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
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> >
>> > --
>> > Odeyemi 'Kayode O.
>> > http://www.sinati.com. t: @charyorde
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Odeyemi 'Kayode O.
> http://www.sinati.com. t: @charyorde



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

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


Re: ResourceReference for resource in webapp dir

Posted by Kayode Odeyemi <dr...@gmail.com>.
On Wed, Feb 8, 2012 at 3:58 PM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> Everything is possible.
> See http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/
> You the request parameter to map to your real resource and load it.
>
> Thanks.

I have all the classes in place now. Could you help with some pointers as
to how to use this in a Page component renderHead? I'm working with
something like this:

private static final UrlResourceReference DASHBOARD_JS = new
UrlResourceReference(
            "/WEB-INF/js/dashboard.js");

@Override
    public void renderHead(IHeaderResponse response) {
        response.renderJavaScriptReference(DASHBOARD_JS);
    }

Application.java
----------------------
super.mountResource("/WEB-INF/js/dashboard.js", new UrlResourceReference());

ContextRelativeURLResource.java
-------------------------------------------------
@Override
    protected ResourceResponse newResourceResponse(Attributes attributes) {
        final ResourceResponse resourceResponse = new ResourceResponse();

        if (resourceResponse.dataNeedsToBeWritten(attributes)) {

            final UrlContextResourceStream urlContextResourceStream = new
UrlContextResourceStream(path);

 resourceResponse.setContentType(urlContextResourceStream.getContentType());

 resourceResponse.setLastModified(urlContextResourceStream.lastModifiedTime());
            resourceResponse.setFileName(path);
            resourceResponse.setWriteCallback(new WriteCallback() {

                @Override
                public void writeData(Attributes attributes) {
                    URL url = null;
                    try {
                        url = urlContextResourceStream.getResourceURL(); //
getURL uses path passed into UrlResourceStream
                    } catch (MalformedURLException ex) {

                        throw new WicketRuntimeException(ex);
                    }
                }
            });
        }
        return resourceResponse;
    }

UrlResourceReference.java
---------------------------------------
@Override
    public IResource getResource() {
        return new ContextRelativeURLResource(getName());

    }

I'm still getting this in the logs:
/w/wicket/resource/org.apache.wicket.Application/WEB-INF/js/dashboard-ver-1328653530609.js

Thank you.

 On Wed, Feb 8, 2012 at 5:30 PM, Kayode Odeyemi <dr...@gmail.com> wrote:
> > On Mon, Feb 6, 2012 at 3:08 PM, Martin Grigorov <mgrigorov@apache.org
> >wrote:
> >
> >> Hi,
> >>
> >> I'd not invest in AbstractResourceDependentResourceReference.
> >> This has been re-implemented in Wicket 6.0 and this class is no more
> there.
> >>
> >> For your case I can recommend you to take a look at Wro4j.
> >> With this library you can merge all resources which depend on each
> >> other at build time. For production you can even minimize them.
> >>
> >
> > Hi Martin,
> >
> > Assuming I decide not to use wro4j and I want to stick to using Wickets
> > iRequestMapper, is it possible for me to achieve a mapping for resources
> > that I have in webapp dir such as:
> >
> > com.company.Dashboard -> /dashboard
> >
> > Such that if I have a js file in webapp/js/dashboard.js, I can simply map
> > it to resolve to /dashboard/js/dashboard.js instead of
> > /com.company.Dashboard/dashboard.js?
> >
> > While digging further into Wicket
> > ResourceReference/Resourcestream/IRequestMapper/IRequestHandler
> > architecture, I noticed that ResourceReference is designed such that a
> > scope always returns Java package as part of the url to the resource.
> >
> > Using Resourcereference/IRequestMapper, is it possible for me to achieve
> > the scenario I described above?
> >
> > Thanks
> >
> >>
> >> On Mon, Feb 6, 2012 at 4:51 PM, Bertrand Guay-Paquet
> >> <be...@step.polymtl.ca> wrote:
> >> > Hi,
> >> >
> >> > Thanks for your reply. I'll try to explain why I require this.
> >> >
> >> > I want to use a ResRef to implement dependent resources based on
> >> > AbstractResourceDependentResourceReference. Essentially, when a
> resource
> >> > A.js is added to the response, I want B.js to be also automatically
> >> added.
> >> >
> >> > A.js and B.js are both located in the webapp dir instead of being
> package
> >> > resources. This is why I wanted to make a ResRef point to the webapp
> dir
> >> > directly.
> >> >
> >> > I don't have much experience with Wicket resources so maybe what I
> >> requested
> >> > originally is the wrong tool for the task.
> >> >
> >> >
> >> > On 04/02/2012 5:07 AM, Martin Grigorov wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> I didn't understand why you want to use ResRef but if this is your
> >> >> requirement then the easiest will be to create your own
> IRequestMapper
> >> >> that handles only your own IRequestHandler that works with your
> ResRef
> >> >> impl.
> >> >> IRequestMapper#mapHandler(IRequestHandler) is the one responsible to
> >> >> create Url when RequestCycle#urlFor() is used.
> >> >> Also take a look at
> >> >> org.apache.wicket.util.string.UrlUtils#rewriteToContextRelative()
> >> >>
> >> >> On Fri, Feb 3, 2012 at 5:40 PM, Bertrand Guay-Paquet
> >> >> <be...@step.polymtl.ca>  wrote:
> >> >>>
> >> >>> Hi,
> >> >>>
> >> >>> I have the following code in my base page:
> >> >>>
> >> >>> public void renderHead(IHeaderResponse response) {
> >> >>>    // scripts/jquery-1.7.1.min.js is in webapp dir
> >> >>>
>  response.renderJavaScriptReference("scripts/jquery-1.7.1.min.js");
> >> >>> }
> >> >>>
> >> >>> How can I transform this direct URL to a ResourceReference?
> >> >>>
> >> >>> PackageResourceReference is not a good fit because I don't want to
> >> store
> >> >>> the
> >> >>> .js in a Java package since it is used by non-wicket pages.
> >> >>>
> >> >>> With ContextRelativeResource, Wicket reads the actual resource and
> >> sends
> >> >>> the
> >> >>> result instead of simply pointing to a URL.
> >> >>>
> >> >>> AbstractResource with its newResourceResponse() abstract method
> >> requires
> >> >>> to
> >> >>> return the actual ResourceResponse which won't allow for a simple
> URL.
> >> >>>
> >> >>> So from what I gather, I would have to fallback to implementing an
> >> >>> IResource's respond(Attributes attributes) method. I looked at the
> >> >>> implementation in AbstractResource but I'm confused about what to do
> >> with
> >> >>> headers since I only want a URL.
> >> >>>
> >> >>> So, does this functionality already exist? If not, do you have a few
> >> >>> pointers to steer me in the right direction?
> >> >>>
> >> >>> Thanks,
> >> >>> Bertrand
> >> >>>
> >> >>>
> ---------------------------------------------------------------------
> >> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>>
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > 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
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
> > --
> > Odeyemi 'Kayode O.
> > http://www.sinati.com. t: @charyorde
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

Re: ResourceReference for resource in webapp dir

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

Everything is possible.
See http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/
You the request parameter to map to your real resource and load it.

On Wed, Feb 8, 2012 at 5:30 PM, Kayode Odeyemi <dr...@gmail.com> wrote:
> On Mon, Feb 6, 2012 at 3:08 PM, Martin Grigorov <mg...@apache.org>wrote:
>
>> Hi,
>>
>> I'd not invest in AbstractResourceDependentResourceReference.
>> This has been re-implemented in Wicket 6.0 and this class is no more there.
>>
>> For your case I can recommend you to take a look at Wro4j.
>> With this library you can merge all resources which depend on each
>> other at build time. For production you can even minimize them.
>>
>
> Hi Martin,
>
> Assuming I decide not to use wro4j and I want to stick to using Wickets
> iRequestMapper, is it possible for me to achieve a mapping for resources
> that I have in webapp dir such as:
>
> com.company.Dashboard -> /dashboard
>
> Such that if I have a js file in webapp/js/dashboard.js, I can simply map
> it to resolve to /dashboard/js/dashboard.js instead of
> /com.company.Dashboard/dashboard.js?
>
> While digging further into Wicket
> ResourceReference/Resourcestream/IRequestMapper/IRequestHandler
> architecture, I noticed that ResourceReference is designed such that a
> scope always returns Java package as part of the url to the resource.
>
> Using Resourcereference/IRequestMapper, is it possible for me to achieve
> the scenario I described above?
>
> Thanks
>
>>
>> On Mon, Feb 6, 2012 at 4:51 PM, Bertrand Guay-Paquet
>> <be...@step.polymtl.ca> wrote:
>> > Hi,
>> >
>> > Thanks for your reply. I'll try to explain why I require this.
>> >
>> > I want to use a ResRef to implement dependent resources based on
>> > AbstractResourceDependentResourceReference. Essentially, when a resource
>> > A.js is added to the response, I want B.js to be also automatically
>> added.
>> >
>> > A.js and B.js are both located in the webapp dir instead of being package
>> > resources. This is why I wanted to make a ResRef point to the webapp dir
>> > directly.
>> >
>> > I don't have much experience with Wicket resources so maybe what I
>> requested
>> > originally is the wrong tool for the task.
>> >
>> >
>> > On 04/02/2012 5:07 AM, Martin Grigorov wrote:
>> >>
>> >> Hi,
>> >>
>> >> I didn't understand why you want to use ResRef but if this is your
>> >> requirement then the easiest will be to create your own IRequestMapper
>> >> that handles only your own IRequestHandler that works with your ResRef
>> >> impl.
>> >> IRequestMapper#mapHandler(IRequestHandler) is the one responsible to
>> >> create Url when RequestCycle#urlFor() is used.
>> >> Also take a look at
>> >> org.apache.wicket.util.string.UrlUtils#rewriteToContextRelative()
>> >>
>> >> On Fri, Feb 3, 2012 at 5:40 PM, Bertrand Guay-Paquet
>> >> <be...@step.polymtl.ca>  wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> I have the following code in my base page:
>> >>>
>> >>> public void renderHead(IHeaderResponse response) {
>> >>>    // scripts/jquery-1.7.1.min.js is in webapp dir
>> >>>    response.renderJavaScriptReference("scripts/jquery-1.7.1.min.js");
>> >>> }
>> >>>
>> >>> How can I transform this direct URL to a ResourceReference?
>> >>>
>> >>> PackageResourceReference is not a good fit because I don't want to
>> store
>> >>> the
>> >>> .js in a Java package since it is used by non-wicket pages.
>> >>>
>> >>> With ContextRelativeResource, Wicket reads the actual resource and
>> sends
>> >>> the
>> >>> result instead of simply pointing to a URL.
>> >>>
>> >>> AbstractResource with its newResourceResponse() abstract method
>> requires
>> >>> to
>> >>> return the actual ResourceResponse which won't allow for a simple URL.
>> >>>
>> >>> So from what I gather, I would have to fallback to implementing an
>> >>> IResource's respond(Attributes attributes) method. I looked at the
>> >>> implementation in AbstractResource but I'm confused about what to do
>> with
>> >>> headers since I only want a URL.
>> >>>
>> >>> So, does this functionality already exist? If not, do you have a few
>> >>> pointers to steer me in the right direction?
>> >>>
>> >>> Thanks,
>> >>> Bertrand
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> For additional commands, e-mail: users-help@wicket.apache.org
>> >>>
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > 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
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Odeyemi 'Kayode O.
> http://www.sinati.com. t: @charyorde



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

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


Re: ResourceReference for resource in webapp dir

Posted by Kayode Odeyemi <dr...@gmail.com>.
On Mon, Feb 6, 2012 at 3:08 PM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> I'd not invest in AbstractResourceDependentResourceReference.
> This has been re-implemented in Wicket 6.0 and this class is no more there.
>
> For your case I can recommend you to take a look at Wro4j.
> With this library you can merge all resources which depend on each
> other at build time. For production you can even minimize them.
>

Hi Martin,

Assuming I decide not to use wro4j and I want to stick to using Wickets
iRequestMapper, is it possible for me to achieve a mapping for resources
that I have in webapp dir such as:

com.company.Dashboard -> /dashboard

Such that if I have a js file in webapp/js/dashboard.js, I can simply map
it to resolve to /dashboard/js/dashboard.js instead of
/com.company.Dashboard/dashboard.js?

While digging further into Wicket
ResourceReference/Resourcestream/IRequestMapper/IRequestHandler
architecture, I noticed that ResourceReference is designed such that a
scope always returns Java package as part of the url to the resource.

Using Resourcereference/IRequestMapper, is it possible for me to achieve
the scenario I described above?

Thanks

>
> On Mon, Feb 6, 2012 at 4:51 PM, Bertrand Guay-Paquet
> <be...@step.polymtl.ca> wrote:
> > Hi,
> >
> > Thanks for your reply. I'll try to explain why I require this.
> >
> > I want to use a ResRef to implement dependent resources based on
> > AbstractResourceDependentResourceReference. Essentially, when a resource
> > A.js is added to the response, I want B.js to be also automatically
> added.
> >
> > A.js and B.js are both located in the webapp dir instead of being package
> > resources. This is why I wanted to make a ResRef point to the webapp dir
> > directly.
> >
> > I don't have much experience with Wicket resources so maybe what I
> requested
> > originally is the wrong tool for the task.
> >
> >
> > On 04/02/2012 5:07 AM, Martin Grigorov wrote:
> >>
> >> Hi,
> >>
> >> I didn't understand why you want to use ResRef but if this is your
> >> requirement then the easiest will be to create your own IRequestMapper
> >> that handles only your own IRequestHandler that works with your ResRef
> >> impl.
> >> IRequestMapper#mapHandler(IRequestHandler) is the one responsible to
> >> create Url when RequestCycle#urlFor() is used.
> >> Also take a look at
> >> org.apache.wicket.util.string.UrlUtils#rewriteToContextRelative()
> >>
> >> On Fri, Feb 3, 2012 at 5:40 PM, Bertrand Guay-Paquet
> >> <be...@step.polymtl.ca>  wrote:
> >>>
> >>> Hi,
> >>>
> >>> I have the following code in my base page:
> >>>
> >>> public void renderHead(IHeaderResponse response) {
> >>>    // scripts/jquery-1.7.1.min.js is in webapp dir
> >>>    response.renderJavaScriptReference("scripts/jquery-1.7.1.min.js");
> >>> }
> >>>
> >>> How can I transform this direct URL to a ResourceReference?
> >>>
> >>> PackageResourceReference is not a good fit because I don't want to
> store
> >>> the
> >>> .js in a Java package since it is used by non-wicket pages.
> >>>
> >>> With ContextRelativeResource, Wicket reads the actual resource and
> sends
> >>> the
> >>> result instead of simply pointing to a URL.
> >>>
> >>> AbstractResource with its newResourceResponse() abstract method
> requires
> >>> to
> >>> return the actual ResourceResponse which won't allow for a simple URL.
> >>>
> >>> So from what I gather, I would have to fallback to implementing an
> >>> IResource's respond(Attributes attributes) method. I looked at the
> >>> implementation in AbstractResource but I'm confused about what to do
> with
> >>> headers since I only want a URL.
> >>>
> >>> So, does this functionality already exist? If not, do you have a few
> >>> pointers to steer me in the right direction?
> >>>
> >>> Thanks,
> >>> Bertrand
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

Re: ResourceReference for resource in webapp dir

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Thanks a lot! I'm glad I gave more details :)

On 06/02/2012 10:08 AM, Martin Grigorov wrote:
> Hi,
>
> I'd not invest in AbstractResourceDependentResourceReference.
> This has been re-implemented in Wicket 6.0 and this class is no more there.
>
> For your case I can recommend you to take a look at Wro4j.
> With this library you can merge all resources which depend on each
> other at build time. For production you can even minimize them.
>
> On Mon, Feb 6, 2012 at 4:51 PM, Bertrand Guay-Paquet
> <be...@step.polymtl.ca>  wrote:
>> Hi,
>>
>> Thanks for your reply. I'll try to explain why I require this.
>>
>> I want to use a ResRef to implement dependent resources based on
>> AbstractResourceDependentResourceReference. Essentially, when a resource
>> A.js is added to the response, I want B.js to be also automatically added.
>>
>> A.js and B.js are both located in the webapp dir instead of being package
>> resources. This is why I wanted to make a ResRef point to the webapp dir
>> directly.
>>
>> I don't have much experience with Wicket resources so maybe what I requested
>> originally is the wrong tool for the task.
>>
>>
>> On 04/02/2012 5:07 AM, Martin Grigorov wrote:
>>> Hi,
>>>
>>> I didn't understand why you want to use ResRef but if this is your
>>> requirement then the easiest will be to create your own IRequestMapper
>>> that handles only your own IRequestHandler that works with your ResRef
>>> impl.
>>> IRequestMapper#mapHandler(IRequestHandler) is the one responsible to
>>> create Url when RequestCycle#urlFor() is used.
>>> Also take a look at
>>> org.apache.wicket.util.string.UrlUtils#rewriteToContextRelative()
>>>
>>> On Fri, Feb 3, 2012 at 5:40 PM, Bertrand Guay-Paquet
>>> <be...@step.polymtl.ca>    wrote:
>>>> Hi,
>>>>
>>>> I have the following code in my base page:
>>>>
>>>> public void renderHead(IHeaderResponse response) {
>>>>     // scripts/jquery-1.7.1.min.js is in webapp dir
>>>>     response.renderJavaScriptReference("scripts/jquery-1.7.1.min.js");
>>>> }
>>>>
>>>> How can I transform this direct URL to a ResourceReference?
>>>>
>>>> PackageResourceReference is not a good fit because I don't want to store
>>>> the
>>>> .js in a Java package since it is used by non-wicket pages.
>>>>
>>>> With ContextRelativeResource, Wicket reads the actual resource and sends
>>>> the
>>>> result instead of simply pointing to a URL.
>>>>
>>>> AbstractResource with its newResourceResponse() abstract method requires
>>>> to
>>>> return the actual ResourceResponse which won't allow for a simple URL.
>>>>
>>>> So from what I gather, I would have to fallback to implementing an
>>>> IResource's respond(Attributes attributes) method. I looked at the
>>>> implementation in AbstractResource but I'm confused about what to do with
>>>> headers since I only want a URL.
>>>>
>>>> So, does this functionality already exist? If not, do you have a few
>>>> pointers to steer me in the right direction?
>>>>
>>>> Thanks,
>>>> Bertrand
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>

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


Re: ResourceReference for resource in webapp dir

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

I'd not invest in AbstractResourceDependentResourceReference.
This has been re-implemented in Wicket 6.0 and this class is no more there.

For your case I can recommend you to take a look at Wro4j.
With this library you can merge all resources which depend on each
other at build time. For production you can even minimize them.

On Mon, Feb 6, 2012 at 4:51 PM, Bertrand Guay-Paquet
<be...@step.polymtl.ca> wrote:
> Hi,
>
> Thanks for your reply. I'll try to explain why I require this.
>
> I want to use a ResRef to implement dependent resources based on
> AbstractResourceDependentResourceReference. Essentially, when a resource
> A.js is added to the response, I want B.js to be also automatically added.
>
> A.js and B.js are both located in the webapp dir instead of being package
> resources. This is why I wanted to make a ResRef point to the webapp dir
> directly.
>
> I don't have much experience with Wicket resources so maybe what I requested
> originally is the wrong tool for the task.
>
>
> On 04/02/2012 5:07 AM, Martin Grigorov wrote:
>>
>> Hi,
>>
>> I didn't understand why you want to use ResRef but if this is your
>> requirement then the easiest will be to create your own IRequestMapper
>> that handles only your own IRequestHandler that works with your ResRef
>> impl.
>> IRequestMapper#mapHandler(IRequestHandler) is the one responsible to
>> create Url when RequestCycle#urlFor() is used.
>> Also take a look at
>> org.apache.wicket.util.string.UrlUtils#rewriteToContextRelative()
>>
>> On Fri, Feb 3, 2012 at 5:40 PM, Bertrand Guay-Paquet
>> <be...@step.polymtl.ca>  wrote:
>>>
>>> Hi,
>>>
>>> I have the following code in my base page:
>>>
>>> public void renderHead(IHeaderResponse response) {
>>>    // scripts/jquery-1.7.1.min.js is in webapp dir
>>>    response.renderJavaScriptReference("scripts/jquery-1.7.1.min.js");
>>> }
>>>
>>> How can I transform this direct URL to a ResourceReference?
>>>
>>> PackageResourceReference is not a good fit because I don't want to store
>>> the
>>> .js in a Java package since it is used by non-wicket pages.
>>>
>>> With ContextRelativeResource, Wicket reads the actual resource and sends
>>> the
>>> result instead of simply pointing to a URL.
>>>
>>> AbstractResource with its newResourceResponse() abstract method requires
>>> to
>>> return the actual ResourceResponse which won't allow for a simple URL.
>>>
>>> So from what I gather, I would have to fallback to implementing an
>>> IResource's respond(Attributes attributes) method. I looked at the
>>> implementation in AbstractResource but I'm confused about what to do with
>>> headers since I only want a URL.
>>>
>>> So, does this functionality already exist? If not, do you have a few
>>> pointers to steer me in the right direction?
>>>
>>> Thanks,
>>> Bertrand
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>
> ---------------------------------------------------------------------
> 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

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


Re: ResourceReference for resource in webapp dir

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Hi,

Thanks for your reply. I'll try to explain why I require this.

I want to use a ResRef to implement dependent resources based on 
AbstractResourceDependentResourceReference. Essentially, when a resource 
A.js is added to the response, I want B.js to be also automatically added.

A.js and B.js are both located in the webapp dir instead of being 
package resources. This is why I wanted to make a ResRef point to the 
webapp dir directly.

I don't have much experience with Wicket resources so maybe what I 
requested originally is the wrong tool for the task.

On 04/02/2012 5:07 AM, Martin Grigorov wrote:
> Hi,
>
> I didn't understand why you want to use ResRef but if this is your
> requirement then the easiest will be to create your own IRequestMapper
> that handles only your own IRequestHandler that works with your ResRef
> impl.
> IRequestMapper#mapHandler(IRequestHandler) is the one responsible to
> create Url when RequestCycle#urlFor() is used.
> Also take a look at
> org.apache.wicket.util.string.UrlUtils#rewriteToContextRelative()
>
> On Fri, Feb 3, 2012 at 5:40 PM, Bertrand Guay-Paquet
> <be...@step.polymtl.ca>  wrote:
>> Hi,
>>
>> I have the following code in my base page:
>>
>> public void renderHead(IHeaderResponse response) {
>>     // scripts/jquery-1.7.1.min.js is in webapp dir
>>     response.renderJavaScriptReference("scripts/jquery-1.7.1.min.js");
>> }
>>
>> How can I transform this direct URL to a ResourceReference?
>>
>> PackageResourceReference is not a good fit because I don't want to store the
>> .js in a Java package since it is used by non-wicket pages.
>>
>> With ContextRelativeResource, Wicket reads the actual resource and sends the
>> result instead of simply pointing to a URL.
>>
>> AbstractResource with its newResourceResponse() abstract method requires to
>> return the actual ResourceResponse which won't allow for a simple URL.
>>
>> So from what I gather, I would have to fallback to implementing an
>> IResource's respond(Attributes attributes) method. I looked at the
>> implementation in AbstractResource but I'm confused about what to do with
>> headers since I only want a URL.
>>
>> So, does this functionality already exist? If not, do you have a few
>> pointers to steer me in the right direction?
>>
>> Thanks,
>> Bertrand
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>

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


Re: ResourceReference for resource in webapp dir

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

I didn't understand why you want to use ResRef but if this is your
requirement then the easiest will be to create your own IRequestMapper
that handles only your own IRequestHandler that works with your ResRef
impl.
IRequestMapper#mapHandler(IRequestHandler) is the one responsible to
create Url when RequestCycle#urlFor() is used.
Also take a look at
org.apache.wicket.util.string.UrlUtils#rewriteToContextRelative()

On Fri, Feb 3, 2012 at 5:40 PM, Bertrand Guay-Paquet
<be...@step.polymtl.ca> wrote:
> Hi,
>
> I have the following code in my base page:
>
> public void renderHead(IHeaderResponse response) {
>    // scripts/jquery-1.7.1.min.js is in webapp dir
>    response.renderJavaScriptReference("scripts/jquery-1.7.1.min.js");
> }
>
> How can I transform this direct URL to a ResourceReference?
>
> PackageResourceReference is not a good fit because I don't want to store the
> .js in a Java package since it is used by non-wicket pages.
>
> With ContextRelativeResource, Wicket reads the actual resource and sends the
> result instead of simply pointing to a URL.
>
> AbstractResource with its newResourceResponse() abstract method requires to
> return the actual ResourceResponse which won't allow for a simple URL.
>
> So from what I gather, I would have to fallback to implementing an
> IResource's respond(Attributes attributes) method. I looked at the
> implementation in AbstractResource but I'm confused about what to do with
> headers since I only want a URL.
>
> So, does this functionality already exist? If not, do you have a few
> pointers to steer me in the right direction?
>
> Thanks,
> Bertrand
>
> ---------------------------------------------------------------------
> 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

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


Re: ResourceReference for resource in webapp dir

Posted by Kayode Odeyemi <dr...@gmail.com>.
On Fri, Feb 3, 2012 at 3:40 PM, Bertrand Guay-Paquet <bernie@step.polymtl.ca
> wrote:

> Hi,
>
> I have the following code in my base page:
>
> public void renderHead(IHeaderResponse response) {
>    // scripts/jquery-1.7.1.min.js is in webapp dir
>    response.**renderJavaScriptReference("**scripts/jquery-1.7.1.min.js");
> }
>
> How can I transform this direct URL to a ResourceReference?
>
> PackageResourceReference is not a good fit because I don't want to store
> the .js in a Java package since it is used by non-wicket pages.
>
> With ContextRelativeResource, Wicket reads the actual resource and sends
> the result instead of simply pointing to a URL.
>
> AbstractResource with its newResourceResponse() abstract method requires
> to return the actual ResourceResponse which won't allow for a simple URL.
>
> So from what I gather, I would have to fallback to implementing an
> IResource's respond(Attributes attributes) method. I looked at the
> implementation in AbstractResource but I'm confused about what to do with
> headers since I only want a URL.
>
> So, does this functionality already exist? If not, do you have a few
> pointers to steer me in the right direction?
>
>
Hi Bertnard,

If you've been able to implement this, please can you share how you did it?

Thanks


-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde