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 2011/09/03 16:25:47 UTC

[Migration 1.5] How to map custom-layout of urls?

Hi,

we have some urls like in following pattern
http://domain.de/ShowTheme-ti123-ki345-ii789.html

With wicket 1.4 we built a BookmarkablePageRequestTargetUrlCodingStrategy
with matches(path) based on a pattern and encoding / decoding the url / 
parameters.

Now i'm not sure how i have to migrate that to wicket 1.5.

I think i have to provide a IRequestMapper.

Is the getCompatibilityScore method the "equivalent" of matches(path)?
Do i have to provide a custom IPageParametersEncoder to encode / decode 
my url / parameters?

Thanks for clearification
Per

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


Re: [Migration 1.5] How to map custom-layout of urls?

Posted by Mike Mander <wi...@gmx.de>.
Thanks Thomas,

that was my first try. But the consequence is that i have to handle the 
page parameter (foo) in the page.
With 1.4 we had a strategy for that with some tests. I would like to 
migrate that.

Mike

> It has some basic support for this, you can just
> mountPage("ShowTheme-${foo}", ShowPage.class);
> and then foo will in the PageParameters
> check MountedMapper javadoc
>
> On Mon, Sep 5, 2011 at 8:10 PM, Per Newgro<pe...@gmx.ch>  wrote:
>
>> Thanks Martin,
>>
>> the parameters are the appendixes to page name (-ti123-ki345-ii789).
>> So i think i have to provide and encoder.
>>
>> Cheers
>> Per
>>
>>
>>   Yes, you need a custom IRequestMapper. You need to set it as root
>>> mapper (see HttpsMapper and CryptoMapper examples).
>>> You don't need custom IPageParametersEncoder unless you encode the
>>> parameters in a special way. The url you showed below has no
>>> parameters at all.
>>>
>>> On Sat, Sep 3, 2011 at 5:25 PM, Per Newgro<pe...@gmx.ch>   wrote:
>>>
>>>> Hi,
>>>>
>>>> we have some urls like in following pattern
>>>> http://domain.de/ShowTheme-**ti123-ki345-ii789.html<http://domain.de/ShowTheme-ti123-ki345-ii789.html>
>>>>
>>>> With wicket 1.4 we built a BookmarkablePageRequestTargetU**
>>>> rlCodingStrategy
>>>> with matches(path) based on a pattern and encoding / decoding the url /
>>>> parameters.
>>>>
>>>> Now i'm not sure how i have to migrate that to wicket 1.5.
>>>>
>>>> I think i have to provide a IRequestMapper.
>>>>
>>>> Is the getCompatibilityScore method the "equivalent" of matches(path)?
>>>> Do i have to provide a custom IPageParametersEncoder to encode / decode
>>>> my
>>>> url / parameters?
>>>>
>>>> Thanks for clearification
>>>> Per
>>>>
>>>> ------------------------------**------------------------------**
>>>> ---------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@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: [Migration 1.5] How to map custom-layout of urls?

Posted by Thomas Matthijs <li...@selckin.be>.
It has some basic support for this, you can just
mountPage("ShowTheme-${foo}", ShowPage.class);
and then foo will in the PageParameters
check MountedMapper javadoc

On Mon, Sep 5, 2011 at 8:10 PM, Per Newgro <pe...@gmx.ch> wrote:

> Thanks Martin,
>
> the parameters are the appendixes to page name (-ti123-ki345-ii789).
> So i think i have to provide and encoder.
>
> Cheers
> Per
>
>
>  Yes, you need a custom IRequestMapper. You need to set it as root
>> mapper (see HttpsMapper and CryptoMapper examples).
>> You don't need custom IPageParametersEncoder unless you encode the
>> parameters in a special way. The url you showed below has no
>> parameters at all.
>>
>> On Sat, Sep 3, 2011 at 5:25 PM, Per Newgro<pe...@gmx.ch>  wrote:
>>
>>> Hi,
>>>
>>> we have some urls like in following pattern
>>> http://domain.de/ShowTheme-**ti123-ki345-ii789.html<http://domain.de/ShowTheme-ti123-ki345-ii789.html>
>>>
>>> With wicket 1.4 we built a BookmarkablePageRequestTargetU**
>>> rlCodingStrategy
>>> with matches(path) based on a pattern and encoding / decoding the url /
>>> parameters.
>>>
>>> Now i'm not sure how i have to migrate that to wicket 1.5.
>>>
>>> I think i have to provide a IRequestMapper.
>>>
>>> Is the getCompatibilityScore method the "equivalent" of matches(path)?
>>> Do i have to provide a custom IPageParametersEncoder to encode / decode
>>> my
>>> url / parameters?
>>>
>>> Thanks for clearification
>>> Per
>>>
>>> ------------------------------**------------------------------**
>>> ---------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: [Migration 1.5] How to map custom-layout of urls?

Posted by Mike Mander <wi...@gmx.de>.
Ok now it's working.

My mapper looks like this.

import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.handler.PageProvider;
import org.apache.wicket.request.handler.RenderPageRequestHandler;
import org.apache.wicket.request.mapper.AbstractComponentMapper;
import org.apache.wicket.util.string.Strings;

public class DetailMovedPageMapper extends AbstractComponentMapper {

     private static final boolean CASE_INSENSITIVE = false;
     public static final String MOUNT_PATH = "ShowDetailPage";

     public DetailMovedPageMapper() {
         super();
     }

     @Override
     public int getCompatibilityScore(Request request) {
         String path = request.getUrl().getPath();
         if (Strings.startsWith(path, getMountPath(), CASE_INSENSITIVE)) {
             String remainder = path.substring(getMountPath().length());
             if 
(remainder.matches("(^\\.html$)|(^-ii\\d*\\.html$)|(^-ti\\d*-.*\\.html$)|(^-ti\\d*-ii\\d*-.*\\.html$)")) 
{
                 return Integer.MAX_VALUE;
             }
         }
         return -1;
     }

     private String getMountPath() {
         return MOUNT_PATH;
     }

     @Override
     public IRequestHandler mapRequest(Request request) {
         Url url = request.getUrl();
         if (url != null && url.getPath().startsWith(getMountPath())) {
             return new RenderPageRequestHandler(new 
PageProvider(DetailMovedPage.class, extractPageParameters(request, 0, 
new DetailMovedPageParametersEncoder())));
         }
         return null;
     }

     @Override
     public Url mapHandler(IRequestHandler requestHandler) {
         // This is special for my usecase because i immidiatly redirect 
this call
         // and i think i don't have to render an url for this component.
         return null;
     }
}

In Application.init i've added the mapper
         getRootRequestMapperAsCompound().add(new DetailMovedPageMapper());

Thanks
Mike
> You need to setup it as root mapper. This way it will be asked first
> to map the request.
>
> On Tue, Sep 6, 2011 at 10:16 AM, Mike Mander<wi...@gmx.de>  wrote:
>> Sorry Martin, but i don't get it to work.
>>
>> I wrote a mapper:
>>
>> import org.apache.wicket.request.IRequestHandler;
>> import org.apache.wicket.request.Request;
>> import org.apache.wicket.request.Url;
>> import org.apache.wicket.request.handler.BookmarkablePageRequestHandler;
>> import org.apache.wicket.request.handler.PageProvider;
>> import org.apache.wicket.request.mapper.AbstractComponentMapper;
>> import org.apache.wicket.util.string.Strings;
>>
>> public class DetailMovedPageMapper extends AbstractComponentMapper {
>>
>>     private static final boolean CASE_INSENSITIVE = false;
>>     public static final String MOUNT_PATH = "ShowDetailPage";
>>
>>     public DetailMovedPageMapper() {
>>         super();
>>     }
>>
>>     @Override
>>     public int getCompatibilityScore(Request request) {
>>         String path = request.getUrl().getPath();
>>         if (Strings.startsWith(path, getMountPath(), CASE_INSENSITIVE)) {
>>             String remainder = path.substring(getMountPath().length());
>>             if
>> (remainder.matches("(^\\.html$)|(^-ii\\d*\\.html$)|(^-ti\\d*-.*\\.html$)|(^-ti\\d*-ii\\d*-.*\\.html$)"))
>> {
>>                 return Integer.MAX_VALUE;
>>             }
>>         }
>>         return -1;
>>     }
>>
>>     private String getMountPath() {
>>         return MOUNT_PATH;
>>     }
>>
>>     @Override
>>     public IRequestHandler mapRequest(Request request) {
>>         return new BookmarkablePageRequestHandler(new
>> PageProvider(DetailMovedPage.class, extractPageParameters(request, 0, new
>> DetailMovedPageParametersEncoder())));
>>     }
>>
>>     @Override
>>     public Url mapHandler(IRequestHandler requestHandler) {
>>         return null;
>>     }
>> }
>>
>> But if i add it in Application.init (mount(new DetailMovedPageMapper());)
>> and call the homepage
>> nothing is displayed (blank page, no markup, no exception or log entry).
>>
>> What i try to do is simply map a call of
>> localhost:8080/ShowDetailPage-ti123-ii456.html
>> to DetailPageMoved(PageParameters[ti=123, ii=456]).
>>
>> Mike
>>
>>> Thanks Martin,
>>>
>>> the parameters are the appendixes to page name (-ti123-ki345-ii789).
>>> So i think i have to provide and encoder.
>>>
>>> Cheers
>>> Per
>>>
>>>> Yes, you need a custom IRequestMapper. You need to set it as root
>>>> mapper (see HttpsMapper and CryptoMapper examples).
>>>> You don't need custom IPageParametersEncoder unless you encode the
>>>> parameters in a special way. The url you showed below has no
>>>> parameters at all.
>>>>
>>>> On Sat, Sep 3, 2011 at 5:25 PM, Per Newgro<pe...@gmx.ch>    wrote:
>>>>> Hi,
>>>>>
>>>>> we have some urls like in following pattern
>>>>> http://domain.de/ShowTheme-ti123-ki345-ii789.html
>>>>>
>>>>> With wicket 1.4 we built a
>>>>> BookmarkablePageRequestTargetUrlCodingStrategy
>>>>> with matches(path) based on a pattern and encoding / decoding the url /
>>>>> parameters.
>>>>>
>>>>> Now i'm not sure how i have to migrate that to wicket 1.5.
>>>>>
>>>>> I think i have to provide a IRequestMapper.
>>>>>
>>>>> Is the getCompatibilityScore method the "equivalent" of matches(path)?
>>>>> Do i have to provide a custom IPageParametersEncoder to encode / decode
>>>>> my
>>>>> url / parameters?
>>>>>
>>>>> Thanks for clearification
>>>>> Per
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>
>>
>
>


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


Re: [Migration 1.5] How to map custom-layout of urls?

Posted by Martin Grigorov <mg...@apache.org>.
You need to setup it as root mapper. This way it will be asked first
to map the request.

On Tue, Sep 6, 2011 at 10:16 AM, Mike Mander <wi...@gmx.de> wrote:
> Sorry Martin, but i don't get it to work.
>
> I wrote a mapper:
>
> import org.apache.wicket.request.IRequestHandler;
> import org.apache.wicket.request.Request;
> import org.apache.wicket.request.Url;
> import org.apache.wicket.request.handler.BookmarkablePageRequestHandler;
> import org.apache.wicket.request.handler.PageProvider;
> import org.apache.wicket.request.mapper.AbstractComponentMapper;
> import org.apache.wicket.util.string.Strings;
>
> public class DetailMovedPageMapper extends AbstractComponentMapper {
>
>    private static final boolean CASE_INSENSITIVE = false;
>    public static final String MOUNT_PATH = "ShowDetailPage";
>
>    public DetailMovedPageMapper() {
>        super();
>    }
>
>    @Override
>    public int getCompatibilityScore(Request request) {
>        String path = request.getUrl().getPath();
>        if (Strings.startsWith(path, getMountPath(), CASE_INSENSITIVE)) {
>            String remainder = path.substring(getMountPath().length());
>            if
> (remainder.matches("(^\\.html$)|(^-ii\\d*\\.html$)|(^-ti\\d*-.*\\.html$)|(^-ti\\d*-ii\\d*-.*\\.html$)"))
> {
>                return Integer.MAX_VALUE;
>            }
>        }
>        return -1;
>    }
>
>    private String getMountPath() {
>        return MOUNT_PATH;
>    }
>
>    @Override
>    public IRequestHandler mapRequest(Request request) {
>        return new BookmarkablePageRequestHandler(new
> PageProvider(DetailMovedPage.class, extractPageParameters(request, 0, new
> DetailMovedPageParametersEncoder())));
>    }
>
>    @Override
>    public Url mapHandler(IRequestHandler requestHandler) {
>        return null;
>    }
> }
>
> But if i add it in Application.init (mount(new DetailMovedPageMapper());)
> and call the homepage
> nothing is displayed (blank page, no markup, no exception or log entry).
>
> What i try to do is simply map a call of
> localhost:8080/ShowDetailPage-ti123-ii456.html
> to DetailPageMoved(PageParameters[ti=123, ii=456]).
>
> Mike
>
>> Thanks Martin,
>>
>> the parameters are the appendixes to page name (-ti123-ki345-ii789).
>> So i think i have to provide and encoder.
>>
>> Cheers
>> Per
>>
>>> Yes, you need a custom IRequestMapper. You need to set it as root
>>> mapper (see HttpsMapper and CryptoMapper examples).
>>> You don't need custom IPageParametersEncoder unless you encode the
>>> parameters in a special way. The url you showed below has no
>>> parameters at all.
>>>
>>> On Sat, Sep 3, 2011 at 5:25 PM, Per Newgro<pe...@gmx.ch>  wrote:
>>>>
>>>> Hi,
>>>>
>>>> we have some urls like in following pattern
>>>> http://domain.de/ShowTheme-ti123-ki345-ii789.html
>>>>
>>>> With wicket 1.4 we built a
>>>> BookmarkablePageRequestTargetUrlCodingStrategy
>>>> with matches(path) based on a pattern and encoding / decoding the url /
>>>> parameters.
>>>>
>>>> Now i'm not sure how i have to migrate that to wicket 1.5.
>>>>
>>>> I think i have to provide a IRequestMapper.
>>>>
>>>> Is the getCompatibilityScore method the "equivalent" of matches(path)?
>>>> Do i have to provide a custom IPageParametersEncoder to encode / decode
>>>> my
>>>> url / parameters?
>>>>
>>>> Thanks for clearification
>>>> Per
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>
>



-- 
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: [Migration 1.5] How to map custom-layout of urls?

Posted by Mike Mander <wi...@gmx.de>.
Sorry Martin, but i don't get it to work.

I wrote a mapper:

import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.handler.BookmarkablePageRequestHandler;
import org.apache.wicket.request.handler.PageProvider;
import org.apache.wicket.request.mapper.AbstractComponentMapper;
import org.apache.wicket.util.string.Strings;

public class DetailMovedPageMapper extends AbstractComponentMapper {

     private static final boolean CASE_INSENSITIVE = false;
     public static final String MOUNT_PATH = "ShowDetailPage";

     public DetailMovedPageMapper() {
         super();
     }

     @Override
     public int getCompatibilityScore(Request request) {
         String path = request.getUrl().getPath();
         if (Strings.startsWith(path, getMountPath(), CASE_INSENSITIVE)) {
             String remainder = path.substring(getMountPath().length());
             if 
(remainder.matches("(^\\.html$)|(^-ii\\d*\\.html$)|(^-ti\\d*-.*\\.html$)|(^-ti\\d*-ii\\d*-.*\\.html$)")) 
{
                 return Integer.MAX_VALUE;
             }
         }
         return -1;
     }

     private String getMountPath() {
         return MOUNT_PATH;
     }

     @Override
     public IRequestHandler mapRequest(Request request) {
         return new BookmarkablePageRequestHandler(new 
PageProvider(DetailMovedPage.class, extractPageParameters(request, 0, 
new DetailMovedPageParametersEncoder())));
     }

     @Override
     public Url mapHandler(IRequestHandler requestHandler) {
         return null;
     }
}

But if i add it in Application.init (mount(new 
DetailMovedPageMapper());) and call the homepage
nothing is displayed (blank page, no markup, no exception or log entry).

What i try to do is simply map a call of 
localhost:8080/ShowDetailPage-ti123-ii456.html
to DetailPageMoved(PageParameters[ti=123, ii=456]).

Mike

> Thanks Martin,
>
> the parameters are the appendixes to page name (-ti123-ki345-ii789).
> So i think i have to provide and encoder.
>
> Cheers
> Per
>
>> Yes, you need a custom IRequestMapper. You need to set it as root
>> mapper (see HttpsMapper and CryptoMapper examples).
>> You don't need custom IPageParametersEncoder unless you encode the
>> parameters in a special way. The url you showed below has no
>> parameters at all.
>>
>> On Sat, Sep 3, 2011 at 5:25 PM, Per Newgro<pe...@gmx.ch>  wrote:
>>> Hi,
>>>
>>> we have some urls like in following pattern
>>> http://domain.de/ShowTheme-ti123-ki345-ii789.html
>>>
>>> With wicket 1.4 we built a 
>>> BookmarkablePageRequestTargetUrlCodingStrategy
>>> with matches(path) based on a pattern and encoding / decoding the url /
>>> parameters.
>>>
>>> Now i'm not sure how i have to migrate that to wicket 1.5.
>>>
>>> I think i have to provide a IRequestMapper.
>>>
>>> Is the getCompatibilityScore method the "equivalent" of matches(path)?
>>> Do i have to provide a custom IPageParametersEncoder to encode / 
>>> decode my
>>> url / parameters?
>>>
>>> Thanks for clearification
>>> Per
>>>
>>> ---------------------------------------------------------------------
>>> 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: [Migration 1.5] How to map custom-layout of urls?

Posted by Per Newgro <pe...@gmx.ch>.
Thanks Martin,

the parameters are the appendixes to page name (-ti123-ki345-ii789).
So i think i have to provide and encoder.

Cheers
Per

> Yes, you need a custom IRequestMapper. You need to set it as root
> mapper (see HttpsMapper and CryptoMapper examples).
> You don't need custom IPageParametersEncoder unless you encode the
> parameters in a special way. The url you showed below has no
> parameters at all.
>
> On Sat, Sep 3, 2011 at 5:25 PM, Per Newgro<pe...@gmx.ch>  wrote:
>> Hi,
>>
>> we have some urls like in following pattern
>> http://domain.de/ShowTheme-ti123-ki345-ii789.html
>>
>> With wicket 1.4 we built a BookmarkablePageRequestTargetUrlCodingStrategy
>> with matches(path) based on a pattern and encoding / decoding the url /
>> parameters.
>>
>> Now i'm not sure how i have to migrate that to wicket 1.5.
>>
>> I think i have to provide a IRequestMapper.
>>
>> Is the getCompatibilityScore method the "equivalent" of matches(path)?
>> Do i have to provide a custom IPageParametersEncoder to encode / decode my
>> url / parameters?
>>
>> Thanks for clearification
>> Per
>>
>> ---------------------------------------------------------------------
>> 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: [Migration 1.5] How to map custom-layout of urls?

Posted by Martin Grigorov <mg...@apache.org>.
Yes, you need a custom IRequestMapper. You need to set it as root
mapper (see HttpsMapper and CryptoMapper examples).
You don't need custom IPageParametersEncoder unless you encode the
parameters in a special way. The url you showed below has no
parameters at all.

On Sat, Sep 3, 2011 at 5:25 PM, Per Newgro <pe...@gmx.ch> wrote:
> Hi,
>
> we have some urls like in following pattern
> http://domain.de/ShowTheme-ti123-ki345-ii789.html
>
> With wicket 1.4 we built a BookmarkablePageRequestTargetUrlCodingStrategy
> with matches(path) based on a pattern and encoding / decoding the url /
> parameters.
>
> Now i'm not sure how i have to migrate that to wicket 1.5.
>
> I think i have to provide a IRequestMapper.
>
> Is the getCompatibilityScore method the "equivalent" of matches(path)?
> Do i have to provide a custom IPageParametersEncoder to encode / decode my
> url / parameters?
>
> Thanks for clearification
> 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

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