You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Matej Knopp <ma...@gmail.com> on 2007/07/29 11:19:25 UTC

Nicer URLs in Wicket

Hi folks,

I've committed two classes that improve Wicket mounted URLs in a
significant way. The URLs stay bookmarkable even after clicking a link
or submitting form, and the AJAX changes are preserved on reload.

Basically, what does is that when you hit a bookmarkable page such as
/my/mount/point
you are immediately redirected to *
/my/mount/point|3|
where |3| is the pageId. The URL is fully bookmarkable. The pageId in
URL is ignored if page with given ID doesn't exist in session or
doesn't match the mount point. Also this preserves the initial page
parameters, so

/my/mount/point/param1/value1 becomes /my/mount/point/param1/value1|3|.

The | separators are configurable and can be changed to e.g. (3) or
anything else you want. (Although [ ] get escaped so it doesn't look
pretty).

Good thing is that the URL remains stable and bookmarkable during the
whole page existence, so you no longer see the ?wicket:interface=:3:::
string in your URL.

Usage is very simple, you just need to mount the page using
HybridUrlCodingStrategy, e.g.

mount(new HybridUrlCodingStrategy("ratings", RatingsPage.class));
mount(new IndexedHybridUrlCodingStrategy("todo-list", TodoList.class));

I've already change all Ajax examples to use this strategy, so to see
it in action you just update wicket and wicket-examples from SVN, or
wait until we redeploy the live examples.

-Matej

* The redirect is necessary for pages with AJAX stuff, so that the
page instance is preserved on reload (otherwise with bookmarkable URL
new instance of page would be created on every reload, which discards
the AJAX changes)

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


Re: Nicer URLs in Wicket

Posted by Matej Knopp <ma...@gmail.com>.
It's only for 1.3. As for the redirect, it is now configurable per
page, there is a constructor parameter that affects whether it
redirects.

-Matej

On 7/30/07, Ayodeji Aladejebi <al...@gmail.com> wrote:
> does it work with wicket 1.2.x? or its only compatible with 1.3
>
> On 7/30/07, Korbinian Bachl <ko...@whiskyworld.de> wrote:
> >
> > Hi Matej,
> >
> > looks really great! - One thing I dont understand ist:
> >
> > You wrote:
> > * The redirect is necessary for pages with AJAX stuff, so that the
> > > > > page instance is preserved on reload (otherwise with bookmarkable
> > URL
> > > > > new instance of page would be created on every reload, which
> > discards
> > > > > the AJAX changes)
> >
> > So, the only pages that need this, are AJAX ones, right? - So why do we
> > have this behaviou for all pages? - Wouldnt it be possible to have this
> > redirect only for pages containing AJAX? (Should be possible to find
> > out, shouldn't it ?)
> >
> > Beside the char: cant you make the seperate sequence choicable by the
> > webapp-programer? - as this was/ is IMHO the biggest pain with the old
> > "interface:wicket" thing - if sb. could have made easily
> > "interface:MyCompany" or sth. like that this wouldnt be a problem for
> > many - as the URL at least would have looked CI-like.
> >
> > Best Regards
> >
> > Korbinian
> >
> >
> > Matej Knopp schrieb:
> > > The example is also online:
> > > http://wicketstuff.org/wicket13/ajax/
> > >
> > > So far I'm not sure what should the default look like
> > > /mount/point|3|
> > > or
> > > /mount/point(3)
> > > or maybe something else?
> > >
> > > Does anyone have an opinion about this?
> > >
> > > -Matej
> >
> > ---------------------------------------------------------------------
> > 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: Nicer URLs in Wicket

Posted by Ayodeji Aladejebi <al...@gmail.com>.
does it work with wicket 1.2.x? or its only compatible with 1.3

On 7/30/07, Korbinian Bachl <ko...@whiskyworld.de> wrote:
>
> Hi Matej,
>
> looks really great! - One thing I dont understand ist:
>
> You wrote:
> * The redirect is necessary for pages with AJAX stuff, so that the
> > > > page instance is preserved on reload (otherwise with bookmarkable
> URL
> > > > new instance of page would be created on every reload, which
> discards
> > > > the AJAX changes)
>
> So, the only pages that need this, are AJAX ones, right? - So why do we
> have this behaviou for all pages? - Wouldnt it be possible to have this
> redirect only for pages containing AJAX? (Should be possible to find
> out, shouldn't it ?)
>
> Beside the char: cant you make the seperate sequence choicable by the
> webapp-programer? - as this was/ is IMHO the biggest pain with the old
> "interface:wicket" thing - if sb. could have made easily
> "interface:MyCompany" or sth. like that this wouldnt be a problem for
> many - as the URL at least would have looked CI-like.
>
> Best Regards
>
> Korbinian
>
>
> Matej Knopp schrieb:
> > The example is also online:
> > http://wicketstuff.org/wicket13/ajax/
> >
> > So far I'm not sure what should the default look like
> > /mount/point|3|
> > or
> > /mount/point(3)
> > or maybe something else?
> >
> > Does anyone have an opinion about this?
> >
> > -Matej
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Nicer URLs in Wicket

Posted by Korbinian Bachl <ko...@whiskyworld.de>.
Hi Matej,

looks really great! - One thing I dont understand ist:

You wrote:
* The redirect is necessary for pages with AJAX stuff, so that the
 > > > page instance is preserved on reload (otherwise with bookmarkable URL
 > > > new instance of page would be created on every reload, which discards
 > > > the AJAX changes)

So, the only pages that need this, are AJAX ones, right? - So why do we 
have this behaviou for all pages? - Wouldnt it be possible to have this 
redirect only for pages containing AJAX? (Should be possible to find 
out, shouldn't it ?)

Beside the char: cant you make the seperate sequence choicable by the 
webapp-programer? - as this was/ is IMHO the biggest pain with the old 
"interface:wicket" thing - if sb. could have made easily 
"interface:MyCompany" or sth. like that this wouldnt be a problem for 
many - as the URL at least would have looked CI-like.

Best Regards

Korbinian


Matej Knopp schrieb:
> The example is also online:
> http://wicketstuff.org/wicket13/ajax/
> 
> So far I'm not sure what should the default look like
> /mount/point|3|
> or
> /mount/point(3)
> or maybe something else?
> 
> Does anyone have an opinion about this?
> 
> -Matej

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


Re: Nicer URLs in Wicket

Posted by Matej Knopp <ma...@gmail.com>.
Nah, that wouldn't work. The separators can only be one character long.

-Matej

On 7/29/07, Johan Compagner <jc...@gmail.com> wrote:
> /mount/point!MK!3!MK!
>
> johan
>
>
> On 7/29/07, Matej Knopp <ma...@gmail.com> wrote:
> >
> > The example is also online:
> > http://wicketstuff.org/wicket13/ajax/
> >
> > So far I'm not sure what should the default look like
> > /mount/point|3|
> > or
> > /mount/point(3)
> > or maybe something else?
> >
> > Does anyone have an opinion about this?
> >
> > -Matej
> >
> > On 7/29/07, Matej Knopp <ma...@gmail.com> wrote:
> > > I'm not entirely sure. First, this only works with mounts, so you need
> > > to mount a page to get this (specify a mount point). Although I don't
> > > see this as a big problem, because if you really care about URLs,
> > > you're mointing your pages anyway.
> > >
> > > But to make it default - I don't know. It's could in theory break
> > > existing applications, e.g. when someone is passing |3| as page
> > > parameter. Not very likely, I know, but it's a bit too late before 1.3
> > > to do such switch IMHO.
> > >
> > > -Matej
> > >
> > > On 7/29/07, ZedroS Schwart <ze...@gmail.com> wrote:
> > > > That's great !
> > > >
> > > > Could it become the basic behavior for wicket url ?
> > > >
> > > > Personally I find the current url behavior in wicket to be quite
> > > > unfriendly. In fact, it's among the few aspects I dislike in wicket :$
> > > >
> > > > ++
> > > > Joseph
> > > >
> > > > On 7/29/07, Matej Knopp <ma...@gmail.com> wrote:
> > > > > Hi folks,
> > > > >
> > > > > I've committed two classes that improve Wicket mounted URLs in a
> > > > > significant way. The URLs stay bookmarkable even after clicking a
> > link
> > > > > or submitting form, and the AJAX changes are preserved on reload.
> > > > >
> > > > > Basically, what does is that when you hit a bookmarkable page such
> > as
> > > > > /my/mount/point
> > > > > you are immediately redirected to *
> > > > > /my/mount/point|3|
> > > > > where |3| is the pageId. The URL is fully bookmarkable. The pageId
> > in
> > > > > URL is ignored if page with given ID doesn't exist in session or
> > > > > doesn't match the mount point. Also this preserves the initial page
> > > > > parameters, so
> > > > >
> > > > > /my/mount/point/param1/value1 becomes
> > /my/mount/point/param1/value1|3|.
> > > > >
> > > > > The | separators are configurable and can be changed to e.g. (3) or
> > > > > anything else you want. (Although [ ] get escaped so it doesn't look
> > > > > pretty).
> > > > >
> > > > > Good thing is that the URL remains stable and bookmarkable during
> > the
> > > > > whole page existence, so you no longer see the
> > ?wicket:interface=:3:::
> > > > > string in your URL.
> > > > >
> > > > > Usage is very simple, you just need to mount the page using
> > > > > HybridUrlCodingStrategy, e.g.
> > > > >
> > > > > mount(new HybridUrlCodingStrategy("ratings", RatingsPage.class));
> > > > > mount(new IndexedHybridUrlCodingStrategy("todo-list", TodoList.class
> > ));
> > > > >
> > > > > I've already change all Ajax examples to use this strategy, so to
> > see
> > > > > it in action you just update wicket and wicket-examples from SVN, or
> > > > > wait until we redeploy the live examples.
> > > > >
> > > > > -Matej
> > > > >
> > > > > * The redirect is necessary for pages with AJAX stuff, so that the
> > > > > page instance is preserved on reload (otherwise with bookmarkable
> > URL
> > > > > new instance of page would be created on every reload, which
> > discards
> > > > > the AJAX changes)
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > 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: Nicer URLs in Wicket

Posted by Johan Compagner <jc...@gmail.com>.
/mount/point!MK!3!MK!

johan


On 7/29/07, Matej Knopp <ma...@gmail.com> wrote:
>
> The example is also online:
> http://wicketstuff.org/wicket13/ajax/
>
> So far I'm not sure what should the default look like
> /mount/point|3|
> or
> /mount/point(3)
> or maybe something else?
>
> Does anyone have an opinion about this?
>
> -Matej
>
> On 7/29/07, Matej Knopp <ma...@gmail.com> wrote:
> > I'm not entirely sure. First, this only works with mounts, so you need
> > to mount a page to get this (specify a mount point). Although I don't
> > see this as a big problem, because if you really care about URLs,
> > you're mointing your pages anyway.
> >
> > But to make it default - I don't know. It's could in theory break
> > existing applications, e.g. when someone is passing |3| as page
> > parameter. Not very likely, I know, but it's a bit too late before 1.3
> > to do such switch IMHO.
> >
> > -Matej
> >
> > On 7/29/07, ZedroS Schwart <ze...@gmail.com> wrote:
> > > That's great !
> > >
> > > Could it become the basic behavior for wicket url ?
> > >
> > > Personally I find the current url behavior in wicket to be quite
> > > unfriendly. In fact, it's among the few aspects I dislike in wicket :$
> > >
> > > ++
> > > Joseph
> > >
> > > On 7/29/07, Matej Knopp <ma...@gmail.com> wrote:
> > > > Hi folks,
> > > >
> > > > I've committed two classes that improve Wicket mounted URLs in a
> > > > significant way. The URLs stay bookmarkable even after clicking a
> link
> > > > or submitting form, and the AJAX changes are preserved on reload.
> > > >
> > > > Basically, what does is that when you hit a bookmarkable page such
> as
> > > > /my/mount/point
> > > > you are immediately redirected to *
> > > > /my/mount/point|3|
> > > > where |3| is the pageId. The URL is fully bookmarkable. The pageId
> in
> > > > URL is ignored if page with given ID doesn't exist in session or
> > > > doesn't match the mount point. Also this preserves the initial page
> > > > parameters, so
> > > >
> > > > /my/mount/point/param1/value1 becomes
> /my/mount/point/param1/value1|3|.
> > > >
> > > > The | separators are configurable and can be changed to e.g. (3) or
> > > > anything else you want. (Although [ ] get escaped so it doesn't look
> > > > pretty).
> > > >
> > > > Good thing is that the URL remains stable and bookmarkable during
> the
> > > > whole page existence, so you no longer see the
> ?wicket:interface=:3:::
> > > > string in your URL.
> > > >
> > > > Usage is very simple, you just need to mount the page using
> > > > HybridUrlCodingStrategy, e.g.
> > > >
> > > > mount(new HybridUrlCodingStrategy("ratings", RatingsPage.class));
> > > > mount(new IndexedHybridUrlCodingStrategy("todo-list", TodoList.class
> ));
> > > >
> > > > I've already change all Ajax examples to use this strategy, so to
> see
> > > > it in action you just update wicket and wicket-examples from SVN, or
> > > > wait until we redeploy the live examples.
> > > >
> > > > -Matej
> > > >
> > > > * The redirect is necessary for pages with AJAX stuff, so that the
> > > > page instance is preserved on reload (otherwise with bookmarkable
> URL
> > > > new instance of page would be created on every reload, which
> discards
> > > > the AJAX changes)
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > 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: Nicer URLs in Wicket

Posted by Matej Knopp <ma...@gmail.com>.
The example is also online:
http://wicketstuff.org/wicket13/ajax/

So far I'm not sure what should the default look like
/mount/point|3|
or
/mount/point(3)
or maybe something else?

Does anyone have an opinion about this?

-Matej

On 7/29/07, Matej Knopp <ma...@gmail.com> wrote:
> I'm not entirely sure. First, this only works with mounts, so you need
> to mount a page to get this (specify a mount point). Although I don't
> see this as a big problem, because if you really care about URLs,
> you're mointing your pages anyway.
>
> But to make it default - I don't know. It's could in theory break
> existing applications, e.g. when someone is passing |3| as page
> parameter. Not very likely, I know, but it's a bit too late before 1.3
> to do such switch IMHO.
>
> -Matej
>
> On 7/29/07, ZedroS Schwart <ze...@gmail.com> wrote:
> > That's great !
> >
> > Could it become the basic behavior for wicket url ?
> >
> > Personally I find the current url behavior in wicket to be quite
> > unfriendly. In fact, it's among the few aspects I dislike in wicket :$
> >
> > ++
> > Joseph
> >
> > On 7/29/07, Matej Knopp <ma...@gmail.com> wrote:
> > > Hi folks,
> > >
> > > I've committed two classes that improve Wicket mounted URLs in a
> > > significant way. The URLs stay bookmarkable even after clicking a link
> > > or submitting form, and the AJAX changes are preserved on reload.
> > >
> > > Basically, what does is that when you hit a bookmarkable page such as
> > > /my/mount/point
> > > you are immediately redirected to *
> > > /my/mount/point|3|
> > > where |3| is the pageId. The URL is fully bookmarkable. The pageId in
> > > URL is ignored if page with given ID doesn't exist in session or
> > > doesn't match the mount point. Also this preserves the initial page
> > > parameters, so
> > >
> > > /my/mount/point/param1/value1 becomes /my/mount/point/param1/value1|3|.
> > >
> > > The | separators are configurable and can be changed to e.g. (3) or
> > > anything else you want. (Although [ ] get escaped so it doesn't look
> > > pretty).
> > >
> > > Good thing is that the URL remains stable and bookmarkable during the
> > > whole page existence, so you no longer see the ?wicket:interface=:3:::
> > > string in your URL.
> > >
> > > Usage is very simple, you just need to mount the page using
> > > HybridUrlCodingStrategy, e.g.
> > >
> > > mount(new HybridUrlCodingStrategy("ratings", RatingsPage.class));
> > > mount(new IndexedHybridUrlCodingStrategy("todo-list", TodoList.class));
> > >
> > > I've already change all Ajax examples to use this strategy, so to see
> > > it in action you just update wicket and wicket-examples from SVN, or
> > > wait until we redeploy the live examples.
> > >
> > > -Matej
> > >
> > > * The redirect is necessary for pages with AJAX stuff, so that the
> > > page instance is preserved on reload (otherwise with bookmarkable URL
> > > new instance of page would be created on every reload, which discards
> > > the AJAX changes)
> > >
> > > ---------------------------------------------------------------------
> > > 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: Nicer URLs in Wicket

Posted by Matej Knopp <ma...@gmail.com>.
I'm not entirely sure. First, this only works with mounts, so you need
to mount a page to get this (specify a mount point). Although I don't
see this as a big problem, because if you really care about URLs,
you're mointing your pages anyway.

But to make it default - I don't know. It's could in theory break
existing applications, e.g. when someone is passing |3| as page
parameter. Not very likely, I know, but it's a bit too late before 1.3
to do such switch IMHO.

-Matej

On 7/29/07, ZedroS Schwart <ze...@gmail.com> wrote:
> That's great !
>
> Could it become the basic behavior for wicket url ?
>
> Personally I find the current url behavior in wicket to be quite
> unfriendly. In fact, it's among the few aspects I dislike in wicket :$
>
> ++
> Joseph
>
> On 7/29/07, Matej Knopp <ma...@gmail.com> wrote:
> > Hi folks,
> >
> > I've committed two classes that improve Wicket mounted URLs in a
> > significant way. The URLs stay bookmarkable even after clicking a link
> > or submitting form, and the AJAX changes are preserved on reload.
> >
> > Basically, what does is that when you hit a bookmarkable page such as
> > /my/mount/point
> > you are immediately redirected to *
> > /my/mount/point|3|
> > where |3| is the pageId. The URL is fully bookmarkable. The pageId in
> > URL is ignored if page with given ID doesn't exist in session or
> > doesn't match the mount point. Also this preserves the initial page
> > parameters, so
> >
> > /my/mount/point/param1/value1 becomes /my/mount/point/param1/value1|3|.
> >
> > The | separators are configurable and can be changed to e.g. (3) or
> > anything else you want. (Although [ ] get escaped so it doesn't look
> > pretty).
> >
> > Good thing is that the URL remains stable and bookmarkable during the
> > whole page existence, so you no longer see the ?wicket:interface=:3:::
> > string in your URL.
> >
> > Usage is very simple, you just need to mount the page using
> > HybridUrlCodingStrategy, e.g.
> >
> > mount(new HybridUrlCodingStrategy("ratings", RatingsPage.class));
> > mount(new IndexedHybridUrlCodingStrategy("todo-list", TodoList.class));
> >
> > I've already change all Ajax examples to use this strategy, so to see
> > it in action you just update wicket and wicket-examples from SVN, or
> > wait until we redeploy the live examples.
> >
> > -Matej
> >
> > * The redirect is necessary for pages with AJAX stuff, so that the
> > page instance is preserved on reload (otherwise with bookmarkable URL
> > new instance of page would be created on every reload, which discards
> > the AJAX changes)
> >
> > ---------------------------------------------------------------------
> > 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: Nicer URLs in Wicket

Posted by ZedroS Schwart <ze...@gmail.com>.
That's great !

Could it become the basic behavior for wicket url ?

Personally I find the current url behavior in wicket to be quite
unfriendly. In fact, it's among the few aspects I dislike in wicket :$

++
Joseph

On 7/29/07, Matej Knopp <ma...@gmail.com> wrote:
> Hi folks,
>
> I've committed two classes that improve Wicket mounted URLs in a
> significant way. The URLs stay bookmarkable even after clicking a link
> or submitting form, and the AJAX changes are preserved on reload.
>
> Basically, what does is that when you hit a bookmarkable page such as
> /my/mount/point
> you are immediately redirected to *
> /my/mount/point|3|
> where |3| is the pageId. The URL is fully bookmarkable. The pageId in
> URL is ignored if page with given ID doesn't exist in session or
> doesn't match the mount point. Also this preserves the initial page
> parameters, so
>
> /my/mount/point/param1/value1 becomes /my/mount/point/param1/value1|3|.
>
> The | separators are configurable and can be changed to e.g. (3) or
> anything else you want. (Although [ ] get escaped so it doesn't look
> pretty).
>
> Good thing is that the URL remains stable and bookmarkable during the
> whole page existence, so you no longer see the ?wicket:interface=:3:::
> string in your URL.
>
> Usage is very simple, you just need to mount the page using
> HybridUrlCodingStrategy, e.g.
>
> mount(new HybridUrlCodingStrategy("ratings", RatingsPage.class));
> mount(new IndexedHybridUrlCodingStrategy("todo-list", TodoList.class));
>
> I've already change all Ajax examples to use this strategy, so to see
> it in action you just update wicket and wicket-examples from SVN, or
> wait until we redeploy the live examples.
>
> -Matej
>
> * The redirect is necessary for pages with AJAX stuff, so that the
> page instance is preserved on reload (otherwise with bookmarkable URL
> new instance of page would be created on every reload, which discards
> the AJAX changes)
>
> ---------------------------------------------------------------------
> 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