Discussion:
wicket 8 / RootRequestMapper vs CompoundRequestMapper
Korbinian Bachl
2018-06-11 09:38:17 UTC
Permalink
Hi,

situation: I need to add some "special" URL handling for certain URLs to have product pages and catalog pages on root. As we also use brix we already have at least one compoundRequestMapper already in use.
Now, wicket seems to have 2 places for that. A new RootRequestMapper e.g.:

YourApplication#init():
old = application.getRootRequestMapper()
application.setRootRequestMapper(new CustomRequestMapper(old))

or a CompoundRequestMapper e.g.:

application.getRootRequestMapperAsCompound().add(new CustomRequestMapper(old));

But what are the pros or cons of using either RootRequestMapper vs CompoundRequestMapper?

From my point of view the only difference is that CompoundRequestMapper gets exectued based on score, where max score gets used first and lower scores later as long as the

public IRequestHandler mapRequest(Request request)

doesnt return null anymore; Did I miss something?


Best,

KB

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Bas Gooren
2018-06-11 10:06:12 UTC
Permalink
Hi!

The Compound mapper is merely a wrapper which can have many child mappers.
The Root mapper is the mapper that wicket calls to do mapping and reverse
mapping. For wicket itself it’s not important whether it is a mapper or
compound mapper.

The higher up in the mapper hierarchy (root -> compound -> compound ->
mapper etc), the earlier it is called.
Note that this is not that important, since the compound mapper works with
scores, but nevertheless if you want to do something like prefixing or
postfixing urls, order does matter.

This is also why, for example, the https mapper should be installed after
all other mappers, and as the root mapper.

If you just want to map some pages, just add the mapper and don’t worry
about where in the hierarchy it is. As long as it returns a score higher
than any other, it will be used.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 11 juni 2018 bij 11:38:31, Korbinian Bachl (
***@whiskyworld.de) schreef:

Hi,

situation: I need to add some "special" URL handling for certain URLs to
have product pages and catalog pages on root. As we also use brix we
already have at least one compoundRequestMapper already in use.
Now, wicket seems to have 2 places for that. A new RootRequestMapper e.g.:

YourApplication#init():
old = application.getRootRequestMapper()
application.setRootRequestMapper(new CustomRequestMapper(old))

or a CompoundRequestMapper e.g.:

application.getRootRequestMapperAsCompound().add(new
CustomRequestMapper(old));

But what are the pros or cons of using either RootRequestMapper vs
CompoundRequestMapper?

From my point of view the only difference is that CompoundRequestMapper
gets exectued based on score, where max score gets used first and lower
scores later as long as the

public IRequestHandler mapRequest(Request request)

doesnt return null anymore; Did I miss something?


Best,

KB

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Korbinian Bachl
2018-06-11 10:33:17 UTC
Permalink
Hi,

thanks a lot for the clarification. So say I want to do some kind of path rewriting/ faking like the apache mod_rewrite does. I then would use a new root mapper and have this one handle the request, fake the url and give it to the "prior" mappers to resolve as in that case I need to make sure I'm the first one in the hierarchy. But where would I then rewrite the generated URLs?

Best,

KB

----- Ursprüngliche Mail -----
Gesendet: Montag, 11. Juni 2018 12:06:12
Betreff: Re: wicket 8 / RootRequestMapper vs CompoundRequestMapper
Hi!
The Compound mapper is merely a wrapper which can have many child mappers.
The Root mapper is the mapper that wicket calls to do mapping and reverse
mapping. For wicket itself it’s not important whether it is a mapper or
compound mapper.
The higher up in the mapper hierarchy (root -> compound -> compound ->
mapper etc), the earlier it is called.
Note that this is not that important, since the compound mapper works with
scores, but nevertheless if you want to do something like prefixing or
postfixing urls, order does matter.
This is also why, for example, the https mapper should be installed after
all other mappers, and as the root mapper.
If you just want to map some pages, just add the mapper and don’t worry
about where in the hierarchy it is. As long as it returns a score higher
than any other, it will be used.
Met vriendelijke groet,
Kind regards,
Bas Gooren
Op 11 juni 2018 bij 11:38:31, Korbinian Bachl (
Hi,
situation: I need to add some "special" URL handling for certain URLs to
have product pages and catalog pages on root. As we also use brix we
already have at least one compoundRequestMapper already in use.
old = application.getRootRequestMapper()
application.setRootRequestMapper(new CustomRequestMapper(old))
application.getRootRequestMapperAsCompound().add(new
CustomRequestMapper(old));
But what are the pros or cons of using either RootRequestMapper vs CompoundRequestMapper?
From my point of view the only difference is that CompoundRequestMapper
gets exectued based on score, where max score gets used first and lower
scores later as long as the
public IRequestHandler mapRequest(Request request)
doesnt return null anymore; Did I miss something?
Best,
KB
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Martin Grigorov
2018-06-11 10:38:43 UTC
Permalink
On Mon, Jun 11, 2018 at 1:33 PM, Korbinian Bachl <
Post by Korbinian Bachl
Hi,
thanks a lot for the clarification. So say I want to do some kind of path
rewriting/ faking like the apache mod_rewrite does. I then would use a new
root mapper and have this one handle the request, fake the url and give it
to the "prior" mappers to resolve as in that case I need to make sure I'm
the first one in the hierarchy. But where would I then rewrite the
generated URLs?
The request mappers are hierarchical.
See how CryptoMapper does it.
An encrypted url comes, CryptoMapper decrypts it, pass it to the underlying
mappers, they handle the request, then produce readable urls for the
links/redirect, and finally CryptoMapper encrypts those.
Post by Korbinian Bachl
Best,
KB
----- UrsprÃŒngliche Mail -----
Gesendet: Montag, 11. Juni 2018 12:06:12
Betreff: Re: wicket 8 / RootRequestMapper vs CompoundRequestMapper
Hi!
The Compound mapper is merely a wrapper which can have many child
mappers.
The Root mapper is the mapper that wicket calls to do mapping and reverse
mapping. For wicket itself it’s not important whether it is a mapper or
compound mapper.
The higher up in the mapper hierarchy (root -> compound -> compound ->
mapper etc), the earlier it is called.
Note that this is not that important, since the compound mapper works
with
scores, but nevertheless if you want to do something like prefixing or
postfixing urls, order does matter.
This is also why, for example, the https mapper should be installed after
all other mappers, and as the root mapper.
If you just want to map some pages, just add the mapper and don’t worry
about where in the hierarchy it is. As long as it returns a score higher
than any other, it will be used.
Met vriendelijke groet,
Kind regards,
Bas Gooren
Op 11 juni 2018 bij 11:38:31, Korbinian Bachl (
Hi,
situation: I need to add some "special" URL handling for certain URLs to
have product pages and catalog pages on root. As we also use brix we
already have at least one compoundRequestMapper already in use.
Now, wicket seems to have 2 places for that. A new RootRequestMapper
old = application.getRootRequestMapper()
application.setRootRequestMapper(new CustomRequestMapper(old))
application.getRootRequestMapperAsCompound().add(new
CustomRequestMapper(old));
But what are the pros or cons of using either RootRequestMapper vs
CompoundRequestMapper?
From my point of view the only difference is that CompoundRequestMapper
gets exectued based on score, where max score gets used first and lower
scores later as long as the
public IRequestHandler mapRequest(Request request)
doesnt return null anymore; Did I miss something?
Best,
KB
---------------------------------------------------------------------
---------------------------------------------------------------------
Korbinian Bachl
2018-06-11 11:53:23 UTC
Permalink
Awesome! - I think I now got this.

So, i need to use
IRequestHandler mapRequest(Request request);
to handle the incoming request to "decode" the fake path/ part
and using
Url mapHandler(IRequestHandler requestHandler);
I can put in any fake path/ part into the URL that goes to the outside.

Thanks a lot Martin! That saves me from doing any JCR/ Brix related hacking as I can now internally map the pages/ paths as I need it :)




----- Ursprüngliche Mail -----
Gesendet: Montag, 11. Juni 2018 12:38:43
Betreff: Re: wicket 8 / RootRequestMapper vs CompoundRequestMapper
On Mon, Jun 11, 2018 at 1:33 PM, Korbinian Bachl <
Post by Korbinian Bachl
Hi,
thanks a lot for the clarification. So say I want to do some kind of path
rewriting/ faking like the apache mod_rewrite does. I then would use a new
root mapper and have this one handle the request, fake the url and give it
to the "prior" mappers to resolve as in that case I need to make sure I'm
the first one in the hierarchy. But where would I then rewrite the
generated URLs?
The request mappers are hierarchical.
See how CryptoMapper does it.
An encrypted url comes, CryptoMapper decrypts it, pass it to the underlying
mappers, they handle the request, then produce readable urls for the
links/redirect, and finally CryptoMapper encrypts those.
Post by Korbinian Bachl
Best,
KB
----- Ursprüngliche Mail -----
Gesendet: Montag, 11. Juni 2018 12:06:12
Betreff: Re: wicket 8 / RootRequestMapper vs CompoundRequestMapper
Hi!
The Compound mapper is merely a wrapper which can have many child
mappers.
The Root mapper is the mapper that wicket calls to do mapping and reverse
mapping. For wicket itself it’s not important whether it is a mapper or
compound mapper.
The higher up in the mapper hierarchy (root -> compound -> compound ->
mapper etc), the earlier it is called.
Note that this is not that important, since the compound mapper works
with
scores, but nevertheless if you want to do something like prefixing or
postfixing urls, order does matter.
This is also why, for example, the https mapper should be installed after
all other mappers, and as the root mapper.
If you just want to map some pages, just add the mapper and don’t worry
about where in the hierarchy it is. As long as it returns a score higher
than any other, it will be used.
Met vriendelijke groet,
Kind regards,
Bas Gooren
Op 11 juni 2018 bij 11:38:31, Korbinian Bachl (
Hi,
situation: I need to add some "special" URL handling for certain URLs to
have product pages and catalog pages on root. As we also use brix we
already have at least one compoundRequestMapper already in use.
Now, wicket seems to have 2 places for that. A new RootRequestMapper
old = application.getRootRequestMapper()
application.setRootRequestMapper(new CustomRequestMapper(old))
application.getRootRequestMapperAsCompound().add(new
CustomRequestMapper(old));
But what are the pros or cons of using either RootRequestMapper vs
CompoundRequestMapper?
From my point of view the only difference is that CompoundRequestMapper
gets exectued based on score, where max score gets used first and lower
scores later as long as the
public IRequestHandler mapRequest(Request request)
doesnt return null anymore; Did I miss something?
Best,
KB
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org

Martin Grigorov
2018-06-11 10:11:32 UTC
Permalink
Hi,

The main method for mounting is WebApplication#mount(IRequestMapper).
It uses getRootRequestMapperAsCompound().add(mapper);, i.e. no matter
whether your root mapper is already compound or not, Wicket will make it
compound by wrapping it in SystemMapper


https://github.com/apache/wicket/blob/950403d5ccea5643e6005450c6b808ea72079d59/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java#L319
https://github.com/apache/wicket/blob/950403d5ccea5643e6005450c6b808ea72079d59/wicket-core/src/main/java/org/apache/wicket/Application.java#L741-L750

On Mon, Jun 11, 2018 at 12:38 PM, Korbinian Bachl <
Post by Korbinian Bachl
Hi,
situation: I need to add some "special" URL handling for certain URLs to
have product pages and catalog pages on root. As we also use brix we
already have at least one compoundRequestMapper already in use.
old = application.getRootRequestMapper()
application.setRootRequestMapper(new CustomRequestMapper(old))
application.getRootRequestMapperAsCompound().add(new
CustomRequestMapper(old));
But what are the pros or cons of using either RootRequestMapper vs CompoundRequestMapper?
From my point of view the only difference is that CompoundRequestMapper
gets exectued based on score, where max score gets used first and lower
scores later as long as the
public IRequestHandler mapRequest(Request request)
doesnt return null anymore; Did I miss something?
Best,
KB
---------------------------------------------------------------------
Korbinian Bachl
2018-06-11 10:34:19 UTC
Permalink
Thanks for pointing me to this!


----- Ursprüngliche Mail -----
Gesendet: Montag, 11. Juni 2018 12:11:32
Betreff: Re: wicket 8 / RootRequestMapper vs CompoundRequestMapper
Hi,
The main method for mounting is WebApplication#mount(IRequestMapper).
It uses getRootRequestMapperAsCompound().add(mapper);, i.e. no matter
whether your root mapper is already compound or not, Wicket will make it
compound by wrapping it in SystemMapper
https://github.com/apache/wicket/blob/950403d5ccea5643e6005450c6b808ea72079d59/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java#L319
https://github.com/apache/wicket/blob/950403d5ccea5643e6005450c6b808ea72079d59/wicket-core/src/main/java/org/apache/wicket/Application.java#L741-L750
On Mon, Jun 11, 2018 at 12:38 PM, Korbinian Bachl <
Post by Korbinian Bachl
Hi,
situation: I need to add some "special" URL handling for certain URLs to
have product pages and catalog pages on root. As we also use brix we
already have at least one compoundRequestMapper already in use.
old = application.getRootRequestMapper()
application.setRootRequestMapper(new CustomRequestMapper(old))
application.getRootRequestMapperAsCompound().add(new
CustomRequestMapper(old));
But what are the pros or cons of using either RootRequestMapper vs CompoundRequestMapper?
From my point of view the only difference is that CompoundRequestMapper
gets exectued based on score, where max score gets used first and lower
scores later as long as the
public IRequestHandler mapRequest(Request request)
doesnt return null anymore; Did I miss something?
Best,
KB
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Loading...