You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by hok <iv...@gmail.com> on 2011/09/15 22:12:12 UTC

Stateful pages without page Id in the url

Hello,
I have an application where all the pages are stateful (have ajax components
in them). However, most of the pages are also bookmarkable and can be fully
restored via the PageParameters. In addition to this, some of pages with
input forms contain unmanaged hibernate entities (unmanaged, because they
can be modified via ajax) and I would prefer to refresh every time the page
is requested from the server, instead of retrieving the page from the page
store. When wicket 1.5 was released I created the following class:

public class NoPageIdMountedMapper extends MountedMapper {

    .......................

    @Override
    protected void encodePageComponentInfo(Url url, PageComponentInfo info)
{
        super.encodePageComponentInfo(url, null);
    }
}

which removed the page Id from the url and this didn't result in any other
change in the behavior. However in the latest wicket revisions (currently in
1.5-SNAPSHOT) this technique doesn't work anymore - the ajax in the pages
using NoPageIdMountedMapper is not working, because the ajax request url
doesn't contain the page id anymore. 

Is it still possible to have stateful pages without having the page id in
the url? Thanks in advance.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Stateful-pages-without-page-Id-in-the-url-tp3816663p3816663.html
Sent from the Users forum 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: MixedParamUrlCodingStrategy and form submit

Posted by Igor Vaynberg <ig...@gmail.com>.
havent used that strategy myself, so no clues. had this been 1.5.x id
be able to help more. debug and see why you are getting the wrong
path.

-igor

On Tue, Sep 20, 2011 at 10:47 PM, Alexander Gubin
<ag...@greatergood.com> wrote:
> so, Igor, any clues?
>
> On Sep 19, 2011, at 8:56 AM, Alexander Gubin wrote:
>
>> 1.4.18
>>
>>
>> On 09/16/2011 04:26 PM, Igor Vaynberg wrote:
>>> what version of wicket?
>>>
>>> -igor
>>>
>>> On Thu, Sep 15, 2011 at 3:08 PM, Alexander Gubin<ag...@greatergood.net>  wrote:
>>>> Googled around, but no clear answer:
>>>>
>>>> In my app I mount a page like this:
>>>>
>>>> mount(new MixedParamUrlCodingStrategy("/store/product", ItemPage.class, new
>>>> String[]{"itemId", "itemName"}));
>>>>
>>>> which gives me a URL
>>>>
>>>> store/product/45336/some-name
>>>>
>>>> I have a form on the resulting page, which on submit sends me to
>>>>
>>>> store/?wicket:interface=:3:itemForm::IFormSubmitListener::
>>>>
>>>> hence 404
>>>>
>>>> looking at form's action I see
>>>> ../../?wicket:interface=:3:itemForm::IFormSubmitListener::,
>>>>
>>>> but I think I need ../?wicket:interface=:3:itemForm::IFormSubmitListener::
>>>>
>>>> What am I doing wrong? Last two elements are parameters and should be
>>>> discounted, but seems like Wicket add's one extra "../" and misses mounted
>>>> page.
>>>>
>>>> Are there better way of configuring Mounting / forms ?
>>>>
>>>> Sincerely,
>>>>
>>>> Alexander
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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: MixedParamUrlCodingStrategy and form submit

Posted by Alexander Gubin <ag...@greatergood.com>.
so, Igor, any clues?

On Sep 19, 2011, at 8:56 AM, Alexander Gubin wrote:

> 1.4.18
> 
> 
> On 09/16/2011 04:26 PM, Igor Vaynberg wrote:
>> what version of wicket?
>> 
>> -igor
>> 
>> On Thu, Sep 15, 2011 at 3:08 PM, Alexander Gubin<ag...@greatergood.net>  wrote:
>>> Googled around, but no clear answer:
>>> 
>>> In my app I mount a page like this:
>>> 
>>> mount(new MixedParamUrlCodingStrategy("/store/product", ItemPage.class, new
>>> String[]{"itemId", "itemName"}));
>>> 
>>> which gives me a URL
>>> 
>>> store/product/45336/some-name
>>> 
>>> I have a form on the resulting page, which on submit sends me to
>>> 
>>> store/?wicket:interface=:3:itemForm::IFormSubmitListener::
>>> 
>>> hence 404
>>> 
>>> looking at form's action I see
>>> ../../?wicket:interface=:3:itemForm::IFormSubmitListener::,
>>> 
>>> but I think I need ../?wicket:interface=:3:itemForm::IFormSubmitListener::
>>> 
>>> What am I doing wrong? Last two elements are parameters and should be
>>> discounted, but seems like Wicket add's one extra "../" and misses mounted
>>> page.
>>> 
>>> Are there better way of configuring Mounting / forms ?
>>> 
>>> Sincerely,
>>> 
>>> Alexander
>>> 
>>> ---------------------------------------------------------------------
>>> 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: MixedParamUrlCodingStrategy and form submit

Posted by Alexander Gubin <ag...@greatergood.net>.
1.4.18


On 09/16/2011 04:26 PM, Igor Vaynberg wrote:
> what version of wicket?
>
> -igor
>
> On Thu, Sep 15, 2011 at 3:08 PM, Alexander Gubin<ag...@greatergood.net>  wrote:
>> Googled around, but no clear answer:
>>
>> In my app I mount a page like this:
>>
>> mount(new MixedParamUrlCodingStrategy("/store/product", ItemPage.class, new
>> String[]{"itemId", "itemName"}));
>>
>> which gives me a URL
>>
>> store/product/45336/some-name
>>
>> I have a form on the resulting page, which on submit sends me to
>>
>> store/?wicket:interface=:3:itemForm::IFormSubmitListener::
>>
>> hence 404
>>
>> looking at form's action I see
>> ../../?wicket:interface=:3:itemForm::IFormSubmitListener::,
>>
>> but I think I need ../?wicket:interface=:3:itemForm::IFormSubmitListener::
>>
>> What am I doing wrong? Last two elements are parameters and should be
>> discounted, but seems like Wicket add's one extra "../" and misses mounted
>> page.
>>
>> Are there better way of configuring Mounting / forms ?
>>
>> Sincerely,
>>
>> Alexander
>>
>> ---------------------------------------------------------------------
>> 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: MixedParamUrlCodingStrategy and form submit

Posted by Igor Vaynberg <ig...@gmail.com>.
what version of wicket?

-igor

On Thu, Sep 15, 2011 at 3:08 PM, Alexander Gubin <ag...@greatergood.net> wrote:
> Googled around, but no clear answer:
>
> In my app I mount a page like this:
>
> mount(new MixedParamUrlCodingStrategy("/store/product", ItemPage.class, new
> String[]{"itemId", "itemName"}));
>
> which gives me a URL
>
> store/product/45336/some-name
>
> I have a form on the resulting page, which on submit sends me to
>
> store/?wicket:interface=:3:itemForm::IFormSubmitListener::
>
> hence 404
>
> looking at form's action I see
> ../../?wicket:interface=:3:itemForm::IFormSubmitListener::,
>
> but I think I need ../?wicket:interface=:3:itemForm::IFormSubmitListener::
>
> What am I doing wrong? Last two elements are parameters and should be
> discounted, but seems like Wicket add's one extra "../" and misses mounted
> page.
>
> Are there better way of configuring Mounting / forms ?
>
> Sincerely,
>
> Alexander
>
> ---------------------------------------------------------------------
> 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: MixedParamUrlCodingStrategy and form submit

Posted by Alexander Gubin <ag...@greatergood.net>.
turns out  that error() and info() calls from onSubmit method send me to 
the wrong path too

I appreciate any ideas on solving this


On 09/15/2011 03:08 PM, Alexander Gubin wrote:
> Googled around, but no clear answer:
>
> In my app I mount a page like this:
>
> mount(new MixedParamUrlCodingStrategy("/store/product", ItemPage.class,
> new String[]{"itemId", "itemName"}));
>
> which gives me a URL
>
> store/product/45336/some-name
>
> I have a form on the resulting page, which on submit sends me to
>
> store/?wicket:interface=:3:itemForm::IFormSubmitListener::
>
> hence 404
>
> looking at form's action I see
> ../../?wicket:interface=:3:itemForm::IFormSubmitListener::,
>
> but I think I need ../?wicket:interface=:3:itemForm::IFormSubmitListener::
>
> What am I doing wrong? Last two elements are parameters and should be
> discounted, but seems like Wicket add's one extra "../" and misses
> mounted page.
>
> Are there better way of configuring Mounting / forms ?
>
> Sincerely,
>
> Alexander
>
> ---------------------------------------------------------------------
> 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


MixedParamUrlCodingStrategy and form submit

Posted by Alexander Gubin <ag...@greatergood.net>.
Googled around, but no clear answer:

In my app I mount a page like this:

mount(new MixedParamUrlCodingStrategy("/store/product", ItemPage.class, 
new String[]{"itemId", "itemName"}));

which gives me a URL

store/product/45336/some-name

I have a form on the resulting page, which on submit sends me to

store/?wicket:interface=:3:itemForm::IFormSubmitListener::

hence 404

looking at form's action I see 
../../?wicket:interface=:3:itemForm::IFormSubmitListener::,

but I think I need ../?wicket:interface=:3:itemForm::IFormSubmitListener::

What am I doing wrong? Last two elements are parameters and should be 
discounted, but seems like Wicket add's one extra "../" and misses 
mounted page.

Are there better way of configuring Mounting / forms ?

Sincerely,

Alexander

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


Re: Stateful pages without page Id in the url

Posted by Dan Retzlaff <dr...@gmail.com>.
We have use cases similar to this. For explanation purposes, consider a User
class that has a collection of Features.

We have an IModel<List<Feature>> implementation called
EntityListModel<Feature>. This class maintains a list of feature IDs within
its implementation (the actual list of Features is transient). It's
essentially the same as LDM, but has logic in onDetach() that replaces its
ID list with IDs for the list's contents at the end of the current request.

So during the editing process, the contents of this list are changed, *but
at no point are any entities serialized into the session.* When the user
eventually clicks Save, the User entity's collection is replaced with the
EntityListModel's collection and pushed to the database.

When I first started with Wicket I did a lot of entity serialization tricks
like you mention. I've since taken a hard and fast rule against it since it
causes a myriad of problems. But of course your mileage may vary. :)

Regards,
Dan

On Thu, Sep 15, 2011 at 4:24 PM, hok <iv...@gmail.com> wrote:

> Thanks Martin,
> your solution seems to work. There are two cases where I need stateful
> pages
> without page id.
> The first one is for purely aesthetic reasons and concerns bookmarkable
> pages which can be opened with page parameters.
> The second is a bit more important. I have a user profile page, where a
> user
> can edit it's profile. This is a (relatively) complex form and, for
> example,
> each user can add/remove contacts from a list (via ajax) and after this to
> submit the form and the changes go to the database. Because of the ajax
> lists I'm unable to use LoadableDetachableModel for the User object (which
> is hibernate entity) and I'm using a regular Model. In this case, if the
> page has id the user can make some changes to the profile and then to save
> them. However, he can also return to an earlier version of the same page,
> which also contains the same unmananged user object, but with older "state"
> and not synchronized with the database (because of the "newer" changes).
> This is a case I'm trying to avoid and by making the page not cache-able
> and
> removing the id I can guarantee that whenever the user opens this page
> it'll
> always be instantiated again with the correct state of the entity. In this
> case though, the "back" functionality provided by the page id's is lost. Do
> you know of a more elegant solution to the problem of having forms,
> containing ajax lists?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Stateful-pages-without-page-Id-in-the-url-tp3816663p3817023.html
> Sent from the Users forum 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: Stateful pages without page Id in the url

Posted by Martin Grigorov <mg...@apache.org>.
It sounds like you need to make your page not versioned :

@Override
	public boolean isVersioned()
	{
		return false;
	}

This way the page will not create new versions of it when you make
changes in the component tree.
When the user presses browser back button she will go to the previous
page instead of to the previous version of that page. This way she
will always see the last state of the page.

On Fri, Sep 16, 2011 at 2:24 AM, hok <iv...@gmail.com> wrote:
> Thanks Martin,
> your solution seems to work. There are two cases where I need stateful pages
> without page id.
> The first one is for purely aesthetic reasons and concerns bookmarkable
> pages which can be opened with page parameters.
> The second is a bit more important. I have a user profile page, where a user
> can edit it's profile. This is a (relatively) complex form and, for example,
> each user can add/remove contacts from a list (via ajax) and after this to
> submit the form and the changes go to the database. Because of the ajax
> lists I'm unable to use LoadableDetachableModel for the User object (which
> is hibernate entity) and I'm using a regular Model. In this case, if the
> page has id the user can make some changes to the profile and then to save
> them. However, he can also return to an earlier version of the same page,
> which also contains the same unmananged user object, but with older "state"
> and not synchronized with the database (because of the "newer" changes).
> This is a case I'm trying to avoid and by making the page not cache-able and
> removing the id I can guarantee that whenever the user opens this page it'll
> always be instantiated again with the correct state of the entity. In this
> case though, the "back" functionality provided by the page id's is lost. Do
> you know of a more elegant solution to the problem of having forms,
> containing ajax lists?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Stateful-pages-without-page-Id-in-the-url-tp3816663p3817023.html
> Sent from the Users forum 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
>
>



-- 
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: Stateful pages without page Id in the url

Posted by hok <iv...@gmail.com>.
Thanks Martin,
your solution seems to work. There are two cases where I need stateful pages
without page id. 
The first one is for purely aesthetic reasons and concerns bookmarkable
pages which can be opened with page parameters.
The second is a bit more important. I have a user profile page, where a user
can edit it's profile. This is a (relatively) complex form and, for example,
each user can add/remove contacts from a list (via ajax) and after this to
submit the form and the changes go to the database. Because of the ajax
lists I'm unable to use LoadableDetachableModel for the User object (which
is hibernate entity) and I'm using a regular Model. In this case, if the
page has id the user can make some changes to the profile and then to save
them. However, he can also return to an earlier version of the same page,
which also contains the same unmananged user object, but with older "state"
and not synchronized with the database (because of the "newer" changes).
This is a case I'm trying to avoid and by making the page not cache-able and
removing the id I can guarantee that whenever the user opens this page it'll
always be instantiated again with the correct state of the entity. In this
case though, the "back" functionality provided by the page id's is lost. Do
you know of a more elegant solution to the problem of having forms,
containing ajax lists? 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Stateful-pages-without-page-Id-in-the-url-tp3816663p3817023.html
Sent from the Users forum 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: Stateful pages without page Id in the url

Posted by Martin Grigorov <mg...@apache.org>.
If WICKET-4014 is the reason then the following workaround should revert it:

@Override
	public Url mapHandler(IRequestHandler requestHandler)
	{
		if (requestHandler instanceof ListenerInterfaceRequestHandler) {
                    return null;
                } else {
                     return super.mapHandler(requestHandler);
                }
        }


Why you are so keen to not have page id in the url ?

On Fri, Sep 16, 2011 at 12:00 AM, hok <iv...@gmail.com> wrote:
> Thanks for the fast response. In my case though, I have pages that are
> defined by their page parameters, so even if the page is expired, pressing
> F5 would reload the same page from the server (and it's not important if the
> state is lost). However if I'm using the aforementioned
> NoPageIdMountedMapper the ajax in the page is not working. So is there
> another way besides this for achieving stateful page without page id in the
> url?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Stateful-pages-without-page-Id-in-the-url-tp3816663p3816779.html
> Sent from the Users forum 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
>
>



-- 
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: Stateful pages without page Id in the url

Posted by hok <iv...@gmail.com>.
Thanks for the fast response. In my case though, I have pages that are
defined by their page parameters, so even if the page is expired, pressing
F5 would reload the same page from the server (and it's not important if the
state is lost). However if I'm using the aforementioned
NoPageIdMountedMapper the ajax in the page is not working. So is there
another way besides this for achieving stateful page without page id in the
url?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Stateful-pages-without-page-Id-in-the-url-tp3816663p3816779.html
Sent from the Users forum 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: Stateful pages without page Id in the url

Posted by Pedro Santos <pe...@gmail.com>.
Hi, yes you can, but F5 will instance the page again and its state will get
lost.
I think the problem is related to
https://issues.apache.org/jira/browse/WICKET-4014
Can you open a ticket so we can track it?

2011/9/15 hok <iv...@gmail.com>

> Hello,
> I have an application where all the pages are stateful (have ajax
> components
> in them). However, most of the pages are also bookmarkable and can be fully
> restored via the PageParameters. In addition to this, some of pages with
> input forms contain unmanaged hibernate entities (unmanaged, because they
> can be modified via ajax) and I would prefer to refresh every time the page
> is requested from the server, instead of retrieving the page from the page
> store. When wicket 1.5 was released I created the following class:
>
> public class NoPageIdMountedMapper extends MountedMapper {
>
>    .......................
>
>    @Override
>    protected void encodePageComponentInfo(Url url, PageComponentInfo info)
> {
>        super.encodePageComponentInfo(url, null);
>    }
> }
>
> which removed the page Id from the url and this didn't result in any other
> change in the behavior. However in the latest wicket revisions (currently
> in
> 1.5-SNAPSHOT) this technique doesn't work anymore - the ajax in the pages
> using NoPageIdMountedMapper is not working, because the ajax request url
> doesn't contain the page id anymore.
>
> Is it still possible to have stateful pages without having the page id in
> the url? Thanks in advance.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Stateful-pages-without-page-Id-in-the-url-tp3816663p3816663.html
> Sent from the Users forum 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
>
>


-- 
Pedro Henrique Oliveira dos Santos