You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by pixologe <pi...@mailinator.com> on 2008/08/13 07:39:33 UTC

Pretty URLs depending on a Page's state (not params)

Hi everybody,

AFAIK it is not possible to have a variable nice URL for a page without
using PageParameters, right?

If I am right: shouldn't it be possible?

Perhaps I'm missing the point or not knowing the internals good enough
(probably both ;-), but what I imagine is to map parts of the URL to
properties of the Page (or Models).

Why? I want to have pretty URLs, but I feel that not *every* view option
should be carried around through PageParameters, for this reason, I am
currently constructing a new page with every request (just for the URL's
sake) with the param I want to see in the URL + having the page's state
(view options - which shall not appear in the URL) saved to the session.

Example: I think it would be cool to be able to do something like this:
FriendListPage page = new FriendListPage();
page.setUser("myUsername");
page.setSorting("asc");
response.setRedirect(page);
and have a resulting URL like
/user/myUsername
while the sorting is not stored in the URL.

and later (on the page itself - when the user wants to switch sorting):
FriendlyPage.this.setSorting("desc");
setResponsePage(FriendlyPage.this);

Would that be feasible?

If there's another way to do it, I would be happy if someone could point it
out to me...

Thanks a lot :)
-- 
View this message in context: http://www.nabble.com/Pretty-URLs-depending-on-a-Page%27s-state-%28not-params%29-tp18957325p18957325.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Pretty URLs depending on a Page's state (not params)

Posted by Erik van Oosten <e....@grons.nl>.
Hi,

You can suppress the version number in the URL. Doing so will make the 
encoder always take the last version of the page (or create a new one 
when it is not present).

More details: 
http://www.nabble.com/More-on-wicket-url-stratergy-td18212748.html#a18273996

Regards,
    Erik.


pixologe wrote:
> Martijn Dashorst wrote:
>   
>> mount your page with hybridurlcodingstrategy
>>
>>     
>
> thanks for pointing this out... i've seen this one before, but somehow
> completely  misunderstood how it is supposed to work :-/
>
> still, it is not exactly what i had in mind, since it attaches a version
> number to every url and AFAIK having the very same content accessible
> through different URLs is something our beloved search engine sees as a
> reason to decrease a page's rating...
>
> But as I thought about it, I realized that it is just not possible to save a
> page state without passing an identifier in the url... this would destroy
> support for conflictless multiple browser windows within a session.
>
> Thus, I will either have to go for one of the mentioned solutions.
>
> Thanks for your input, it was very helpful :)
>
>
>
>
>   


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


Re: Pretty URLs depending on a Page's state (not params)

Posted by pixologe <pi...@mailinator.com>.

Martijn Dashorst wrote:
> 
> mount your page with hybridurlcodingstrategy
> 

thanks for pointing this out... i've seen this one before, but somehow
completely  misunderstood how it is supposed to work :-/

still, it is not exactly what i had in mind, since it attaches a version
number to every url and AFAIK having the very same content accessible
through different URLs is something our beloved search engine sees as a
reason to decrease a page's rating...

But as I thought about it, I realized that it is just not possible to save a
page state without passing an identifier in the url... this would destroy
support for conflictless multiple browser windows within a session.

Thus, I will either have to go for one of the mentioned solutions.

Thanks for your input, it was very helpful :)




-- 
View this message in context: http://www.nabble.com/Pretty-URLs-depending-on-a-Page%27s-state-%28not-params%29-tp18957325p18960904.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Pretty URLs depending on a Page's state (not params)

Posted by Martijn Dashorst <ma...@gmail.com>.
mount your page with hybridurlcodingstrategy

Martijn

On Wed, Aug 13, 2008 at 9:38 AM, pixologe <pi...@mailinator.com> wrote:
>
>> no. having a nice/bookmarkble url means having all the state in the
>> url.
>
> hmmm i'm not sure... sometimes i'd like to have a pretty url, even if it
> does not hold the exact state of the page... in my example: the re-sorted
> list of friends would be still bookmarkable, however the sorting would be
> reset when the bookmarked URL is loaded.
>
> the problem is also that a lot of components produce non-pretty URLs because
> they need to hold state, e.g.  PagingNavigator - I think it would be great
> if they could hold state, but the resulting pages would still be
> pretty-URLed (even if the state (e.g. offset) gets lost in the URL)
>
>
>
>> you can also encapsulate parameter creation within a page factory
>> method to make it cleaner
>
>> setresponsepage(mypage.class, mypage.params("myusername", "asc"));
>
> yeah, that is a good idea, thanks for inspiration :)
>
> but still I would be even happier with wicket if there was a hybrid solution
> which enabled a page to hold state beyond its pretty URL params
>
>
> --
> View this message in context: http://www.nabble.com/Pretty-URLs-depending-on-a-Page%27s-state-%28not-params%29-tp18957325p18958323.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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


Re: Pretty URLs depending on a Page's state (not params)

Posted by Matej Knopp <ma...@gmail.com>.
On Wed, Aug 13, 2008 at 5:01 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> On Wed, Aug 13, 2008 at 12:38 AM, pixologe <pi...@mailinator.com> wrote:
>> but still I would be even happier with wicket if there was a hybrid solution
>> which enabled a page to hold state beyond its pretty URL params
>
There will be one, I plan such thing for 1.5. :) Based on how Brix handles URLs.

-Matej


> you are more then welcome to create one and share it with the rest of us.
>
> -igor
>
>>
>>
>> --
>> View this message in context: http://www.nabble.com/Pretty-URLs-depending-on-a-Page%27s-state-%28not-params%29-tp18957325p18958323.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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: Pretty URLs depending on a Page's state (not params)

Posted by Igor Vaynberg <ig...@gmail.com>.
On Wed, Aug 13, 2008 at 12:38 AM, pixologe <pi...@mailinator.com> wrote:
> but still I would be even happier with wicket if there was a hybrid solution
> which enabled a page to hold state beyond its pretty URL params

you are more then welcome to create one and share it with the rest of us.

-igor

>
>
> --
> View this message in context: http://www.nabble.com/Pretty-URLs-depending-on-a-Page%27s-state-%28not-params%29-tp18957325p18958323.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: Pretty URLs depending on a Page's state (not params)

Posted by pixologe <pi...@mailinator.com>.
> no. having a nice/bookmarkble url means having all the state in the
> url. 

hmmm i'm not sure... sometimes i'd like to have a pretty url, even if it
does not hold the exact state of the page... in my example: the re-sorted
list of friends would be still bookmarkable, however the sorting would be
reset when the bookmarked URL is loaded.

the problem is also that a lot of components produce non-pretty URLs because
they need to hold state, e.g.  PagingNavigator - I think it would be great
if they could hold state, but the resulting pages would still be
pretty-URLed (even if the state (e.g. offset) gets lost in the URL)



> you can also encapsulate parameter creation within a page factory
> method to make it cleaner

> setresponsepage(mypage.class, mypage.params("myusername", "asc"));

yeah, that is a good idea, thanks for inspiration :)

but still I would be even happier with wicket if there was a hybrid solution
which enabled a page to hold state beyond its pretty URL params


-- 
View this message in context: http://www.nabble.com/Pretty-URLs-depending-on-a-Page%27s-state-%28not-params%29-tp18957325p18958323.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Pretty URLs depending on a Page's state (not params)

Posted by Igor Vaynberg <ig...@gmail.com>.
On Tue, Aug 12, 2008 at 10:39 PM, pixologe <pi...@mailinator.com> wrote:
>
> Hi everybody,
>
> AFAIK it is not possible to have a variable nice URL for a page without
> using PageParameters, right?
>
> If I am right: shouldn't it be possible?

no. having a nice/bookmarkble url means having all the state in the
url. this means you can only effectively have state that is composed
of strings, this is what pageparameters does. when this url is invoked
wicket has to figure out how to construct the page object, eg which
constructor to use. that is why we have pageparameters, it helps you
manage the state and help wicket find the right constructor.

> Example: I think it would be cool to be able to do something like this:
> FriendListPage page = new FriendListPage();
> page.setUser("myUsername");
> page.setSorting("asc");
> response.setRedirect(page);
> and have a resulting URL like
> /user/myUsername
> while the sorting is not stored in the URL.

and you can do it like this:
PageParameters params=new PageParameters();
params.set("user","myusername");
params.set("sort","asc");
setresponsepage(mypage.class, params);

you can also encapsulate parameter creation within a page factory
method to make it cleaner

setresponsepage(mypage.class, mypage.params("myusername", "asc"));

-igor




>
> and later (on the page itself - when the user wants to switch sorting):
> FriendlyPage.this.setSorting("desc");
> setResponsePage(FriendlyPage.this);
>
> Would that be feasible?
>
> If there's another way to do it, I would be happy if someone could point it
> out to me...
>
> Thanks a lot :)
> --
> View this message in context: http://www.nabble.com/Pretty-URLs-depending-on-a-Page%27s-state-%28not-params%29-tp18957325p18957325.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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