Re: Stateful pages without page Id in the url

2011-09-16 Thread Martin Grigorov
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 ivanvasi...@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-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



Stateful pages without page Id in the url

2011-09-15 Thread hok
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Stateful pages without page Id in the url

2011-09-15 Thread Pedro Santos
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 ivanvasi...@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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Pedro Henrique Oliveira dos Santos


Re: Stateful pages without page Id in the url

2011-09-15 Thread hok
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Stateful pages without page Id in the url

2011-09-15 Thread Martin Grigorov
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 ivanvasi...@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-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: Stateful pages without page Id in the url

2011-09-15 Thread hok
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Stateful pages without page Id in the url

2011-09-15 Thread Dan Retzlaff
We have use cases similar to this. For explanation purposes, consider a User
class that has a collection of Features.

We have an IModelListFeature implementation called
EntityListModelFeature. 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 ivanvasi...@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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org