Re: Understanding Wicket 1.5 page mapping

2011-04-23 Thread Alexandros Karypidis

Hello,

Could you post some pseudo-code on what your request mapper looks like? I  
have a similar use-case but I wasn't able to follow. I created a  
MyRequestMapper class that wraps the default root mapper:


setRootRequestMapper(new MyRequestMapper(getRootRequestMapper()));


public class MyRequestMapper implements IRequestMapper {
private final IRequestMapper wrappedMapper;


public MyRequestMapper(IRequestMapper wrappedMapper) {
this.wrappedMapper = wrappedMapper;
}
...
mapRequest()
mapHandler()
getCompativilityScore()
...
}

Currently I delegate to the wrapped handler. What I would like to do is  
peek at the URL (i.e. request.getUrl()), then decide based on some logic  
which page to render. However, mapRequest() returns an IRequestHandler.  
I would've liked to return same page class like this:



@Override
public IRequestHandler mapRequest(Request request) {
ListString segments = request.getUrl().getSegments();
if (existsPerson(segments.get(0)) {
==  return PersonPage.class;
} else if (existsProduct(segments.get(0)) {
==  return ProductPage.class;
}
return wrappedMapper.mapRequest(request);
}

How would I go about doing that?

On Fri, 22 Apr 2011 23:48:54 +0300, drewzilla80 andrew.eas...@gmail.com  
wrote:


Thanks, Martin. That's what I already ended up doing as it turns out (I  
dug

into the code and noticed the method you specified). I've got my whole
original use case working very nicely indeed - thanks for your help.

dz

--
View this message in context:  
http://apache-wicket.1842946.n4.nabble.com/Understanding-Wicket-1-5-page-mapping-tp3467619p3468850.html

Sent from the Users forum mailing list archive at Nabble.com.

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


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



Re: Understanding Wicket 1.5 page mapping

2011-04-23 Thread drewzilla80
Try creating a method such as this;

private IRequestHandler renderPage(Class? extends IRequestablePage
pageClass, PageParameters pageParameters) {
PageProvider pageProvider = new PageProvider(pageClass,
pageParameters);
pageProvider.setPageSource(Application.get().getMapperContext());
return new RenderPageRequestHandler(pageProvider,
RenderPageRequestHandler.RedirectPolicy.NEVER_REDIRECT);
}

You can call this method from your mapRequest(...) implementation, passing
in the page class and any parameters to go with it.

You don't theoretically need to specify the redirect policy but it is a
workaround due to a bug in 1.5-rc3 that issues 302 redirect when it
shouldn't be doing so.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Understanding-Wicket-1-5-page-mapping-tp3467619p3469896.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Understanding Wicket 1.5 page mapping

2011-04-23 Thread Alexandros Karypidis

Thx!

On Sat, 23 Apr 2011 14:11:56 +0300, Alexandros Karypidis  
akary...@yahoo.gr wrote:



Hello,

Could you post some pseudo-code on what your request mapper looks like?  
I have a similar use-case but I wasn't able to follow. I created a  
MyRequestMapper class that wraps the default root mapper:


setRootRequestMapper(new MyRequestMapper(getRootRequestMapper()));


public class MyRequestMapper implements IRequestMapper {
private final IRequestMapper wrappedMapper;


public MyRequestMapper(IRequestMapper wrappedMapper) {
this.wrappedMapper = wrappedMapper;
}
...
mapRequest()
mapHandler()
getCompativilityScore()
...
}

Currently I delegate to the wrapped handler. What I would like to do  
is peek at the URL (i.e. request.getUrl()), then decide based on some  
logic which page to render. However, mapRequest() returns an  
IRequestHandler. I would've liked to return same page class like this:



@Override
public IRequestHandler mapRequest(Request request) {
ListString segments = request.getUrl().getSegments();
if (existsPerson(segments.get(0)) {
==  return PersonPage.class;
} else if (existsProduct(segments.get(0)) {
==  return ProductPage.class;
}
return wrappedMapper.mapRequest(request);
}

How would I go about doing that?

On Fri, 22 Apr 2011 23:48:54 +0300, drewzilla80  
andrew.eas...@gmail.com wrote:


Thanks, Martin. That's what I already ended up doing as it turns out (I  
dug

into the code and noticed the method you specified). I've got my whole
original use case working very nicely indeed - thanks for your help.

dz

--
View this message in context:  
http://apache-wicket.1842946.n4.nabble.com/Understanding-Wicket-1-5-page-mapping-tp3467619p3468850.html

Sent from the Users forum mailing list archive at Nabble.com.

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


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


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



Understanding Wicket 1.5 page mapping

2011-04-22 Thread drewzilla80
Hi,

I'm really keen to have a clearer understanding of the page mapping changes
in Wicket 1.5 - right now it is still not totally clear in my mind.

The best way to explain is by highlighting some requirements I have based on
the URL scheme we are trying to achieve in a project.

We have the concept of Locations and Categories. To visit a location
page, the following URL would be used:

www.mycompany.com/someLocation

To visit a category page, the URL would be:

www.mycompany.com/someCategory

Additionally, a search page exists combining a location and a category - the
url being:

www.mycompany.com/someLocation/someCategory

So we have three page types:

- Location page 
- Category page
- Combination location and category page (a search page)

I've not found a solution to implementing this URL scheme using Wicket. One
issue being that the URLs are dynamic, i.e. we need to lookup locations and
categories from a database to determine whether a specified URL is actually
a location page, category page, search page or none of the above.

The steps would be:

1. If only a single path...
2. If it is a valid category, forward to CategoryPage.class
3. If it is a valid location, forward to LocationPage.class
4. If there is a second path element (validLocation/validCategory) forward
to SearchPage.class
5. If no matching page found by now, fall through to other mappers/handlers
to handle the URL

My problem up to now is that none of these pages is prefixed with anything
to uniquely identify them, e.g.

/location/someLocation
/category/someCategory

and thus I need to perform logic (including database calls) to determine the
semantics of the URL before I know what the intended destination is.

Hopefully I've been clear enough as to what the issue is I'm trying to
solve. Having briefly read up about the great work that is being done in
Wicket 1.5, I'm thinking that maybe I could achieve this now.

I'd be really grateful for some ideas/opinions on this.

Thanks,

dz

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Understanding-Wicket-1-5-page-mapping-tp3467619p3467619.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Understanding Wicket 1.5 page mapping

2011-04-22 Thread Martin Grigorov
Hi,

Create a new IRequestMapper and set it as root mapper - see the
examples for HttpsMapper and CryptoMapper to see how.
This new mapper will process the URL and decide which page to use
(CategoryPage vs. LocationPage) and use BookmarkablePageRequestHandler
to render it.

The new mapper should be compound (ICompoundRequestMapper) and
fallback to default mappers for Wicket internal works (link/form
listeners, ajax, ...).

Have fun!

On Fri, Apr 22, 2011 at 11:46 AM, drewzilla80 andrew.eas...@gmail.com wrote:
 Hi,

 I'm really keen to have a clearer understanding of the page mapping changes
 in Wicket 1.5 - right now it is still not totally clear in my mind.

 The best way to explain is by highlighting some requirements I have based on
 the URL scheme we are trying to achieve in a project.

 We have the concept of Locations and Categories. To visit a location
 page, the following URL would be used:

 www.mycompany.com/someLocation

 To visit a category page, the URL would be:

 www.mycompany.com/someCategory

 Additionally, a search page exists combining a location and a category - the
 url being:

 www.mycompany.com/someLocation/someCategory

 So we have three page types:

 - Location page
 - Category page
 - Combination location and category page (a search page)

 I've not found a solution to implementing this URL scheme using Wicket. One
 issue being that the URLs are dynamic, i.e. we need to lookup locations and
 categories from a database to determine whether a specified URL is actually
 a location page, category page, search page or none of the above.

 The steps would be:

 1. If only a single path...
 2. If it is a valid category, forward to CategoryPage.class
 3. If it is a valid location, forward to LocationPage.class
 4. If there is a second path element (validLocation/validCategory) forward
 to SearchPage.class
 5. If no matching page found by now, fall through to other mappers/handlers
 to handle the URL

 My problem up to now is that none of these pages is prefixed with anything
 to uniquely identify them, e.g.

 /location/someLocation
 /category/someCategory

 and thus I need to perform logic (including database calls) to determine the
 semantics of the URL before I know what the intended destination is.

 Hopefully I've been clear enough as to what the issue is I'm trying to
 solve. Having briefly read up about the great work that is being done in
 Wicket 1.5, I'm thinking that maybe I could achieve this now.

 I'd be really grateful for some ideas/opinions on this.

 Thanks,

 dz

 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Understanding-Wicket-1-5-page-mapping-tp3467619p3467619.html
 Sent from the Users forum mailing list archive at Nabble.com.

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





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

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



Re: Understanding Wicket 1.5 page mapping

2011-04-22 Thread drewzilla80
Hey Martin.

Thanks for the awesome reply speed!

It is amazing how committed you guys are to solving the real world problems
we face as developers. Wicket is such a cool framework and it's great to see
these new features constantly evolving to add the sort of flexibility needed
when there's an SEO analyst breathing down your neck!

Thanks again!

dz

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Understanding-Wicket-1-5-page-mapping-tp3467619p3467643.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Understanding Wicket 1.5 page mapping

2011-04-22 Thread drewzilla80
Martin,

Just playing with the code now - I'm afraid I'm not sure exactly what you
mean by:

The new mapper should be compound (ICompoundRequestMapper) and 
fallback to default mappers for Wicket internal works (link/form 
listeners, ajax, ...)

Could you elaborate briefly on this piece?

Thanks,

dz

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Understanding-Wicket-1-5-page-mapping-tp3467619p3467769.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Understanding Wicket 1.5 page mapping

2011-04-22 Thread Martin Grigorov
Ignore this.
getRootRequestMapperAsCompound() will convert it for you anyway.
Just follow how Https and Crypto mappers work

On Fri, Apr 22, 2011 at 1:54 PM, drewzilla80 andrew.eas...@gmail.com wrote:
 Martin,

 Just playing with the code now - I'm afraid I'm not sure exactly what you
 mean by:

 The new mapper should be compound (ICompoundRequestMapper) and
 fallback to default mappers for Wicket internal works (link/form
 listeners, ajax, ...)

 Could you elaborate briefly on this piece?

 Thanks,

 dz

 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Understanding-Wicket-1-5-page-mapping-tp3467619p3467769.html
 Sent from the Users forum mailing list archive at Nabble.com.

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





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

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



Re: Understanding Wicket 1.5 page mapping

2011-04-22 Thread drewzilla80
Thanks, Martin. That's what I already ended up doing as it turns out (I dug
into the code and noticed the method you specified). I've got my whole
original use case working very nicely indeed - thanks for your help.

dz

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Understanding-Wicket-1-5-page-mapping-tp3467619p3468850.html
Sent from the Users forum mailing list archive at Nabble.com.

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