You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Alexander Adam, Emia Systems" <ad...@emiasys.com> on 2012/07/18 13:53:10 UTC

Wicket and Versioning

Hi!

I am pretty much lost with Wicket 1.5.7 and versioning. What happens is this: I've deactivated versioning by setting serVersioned(false) in my page's constructor.
However, still the page id gets increment each time I call the exact same url in my browser i.e. home/?0, home/?1, home/?2, etc.
I simply don't want this behavior, I want to have a stateful page with *exactly* one state at a given time for a given user, not more. How can I do that?
I want page refreshes to destroy anything ajax might have created and the such still, I want to be stateful to properly use forms, clickable links etc..

please advise, I'm almost giving up :(

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


Re: Wicket and Versioning

Posted by Martin Grigorov <mg...@apache.org>.
BookmarkablePageLink uses Class<Page>, not a Page (an instance), so it
creates a new instance of this class each time the user clicks on the
link.
You need to keep a Map<Class<Page>, PageReference> and a Link that
when clicked extracts the proper Page instance from the PageReference
and schedules it.

On Thu, Jul 19, 2012 at 12:27 PM, Alexander Adam, Emia Systems
<ad...@emiasys.com> wrote:
> Hi,
>
> Thanks a lot, however, doing that for every page seems to be though.
> Isn't there a "standard way" in wicket for doing this? I cannot believe such a base case not be covered besides workarounds.. I mean, linking through a Bookmarkable link to my stateful page creates a new version on each click without any changes doesn't make any sense for most applications I think... please, anyone to turn this off? Why does setVersioned have no effect either??
>
> Thanks a bunch!!
> Alex
>
> Am 18.07.2012 um 16:38 schrieb Andrea Del Bene:
>
>> Hi,
>>
>> you could try with the following solution:
>>
>> - Mount a stateless page on your desired path (let's say "/home")
>> - This page should do nothing but redirect user to your stateful page, but instead of creating a new instance of it each time, it will save into session your stateful page to use it for the next requests. Its constructor should look like this:
>>
>>        Page page = null;
>>
>>        if(Session.get().getAttribute("page") == null){
>>            Session.get().bind();
>>            page = new YourPage();
>>            Session.get().setAttribute("page", page);
>>        }else{
>>            page =(Page) Session.get().getAttribute("page");
>>        }
>>
>>        setResponsePage(page);
>>
>>
>> Inside YourPage you should anyway call serVersioned(false).
>>> One more thing --> I don't see any use in versioning in my case: My base page is stateful though that means each and every link I use will lead to a new version number polluting the user's browser history with all the same link even though there has NOTHING changed on the page!? Please, there has to be a way to turn that off.. I was trying to return a PageManager that returns supportsVersioning = false still no effect..
>>>
>>> NOTE: I do not want to only get this out of the url but I want to get RID of this feature as it pollutes the session by storing a serialized version of all but the same page...
>>>
>>> thanks!!
>>> Alex
>>>
>>>
>>> Am 18.07.2012 um 14:08 schrieb Josh Kamau:
>>>
>>>> Now create something like this
>>>>
>>>> public class CleanUrlMapper extends MountedMapper {
>>>>
>>>>  public CleanUrlMapper(String mountPath, Class<? extends IRequestablePage>
>>>> pageClass) {
>>>>    super(mountPath, pageClass, new PageParametersEncoder());
>>>>  }
>>>>
>>>>  @Override
>>>>  protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
>>>>    // do nothing so that component info does not get rendered in url
>>>>  }
>>>>
>>>>  @Override
>>>>  public Url mapHandler(IRequestHandler requestHandler)
>>>>  {
>>>>      if (requestHandler instanceof ListenerInterfaceRequestHandler) {
>>>>          return null;
>>>>      } else {
>>>>           return super.mapHandler(requestHandler);
>>>>      }
>>>>  }
>>>> }
>>>>
>>>> and then mount your pages like this
>>>>
>>>> mount(new CleanUrlMapper("/home", HomePage.class));
>>>>
>>>>
>>>> Atleast thats what i do to achieve something like what you want.
>>>>
>>>> Josh.
>>>>
>>>> On Wed, Jul 18, 2012 at 2:53 PM, Alexander Adam, Emia Systems <
>>>> adam@emiasys.com> wrote:
>>>>
>>>>> Hi!
>>>>>
>>>>> I am pretty much lost with Wicket 1.5.7 and versioning. What happens is
>>>>> this: I've deactivated versioning by setting serVersioned(false) in my
>>>>> page's constructor.
>>>>> However, still the page id gets increment each time I call the exact same
>>>>> url in my browser i.e. home/?0, home/?1, home/?2, etc.
>>>>> I simply don't want this behavior, I want to have a stateful page with
>>>>> *exactly* one state at a given time for a given user, not more. How can I
>>>>> do that?
>>>>> I want page refreshes to destroy anything ajax might have created and the
>>>>> such still, I want to be stateful to properly use forms, clickable links
>>>>> etc..
>>>>>
>>>>> please advise, I'm almost giving up :(
>>>>>
>>>>> thank you!!
>>>>> Alex
>>>>> ---------------------------------------------------------------------
>>>>> 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
>



-- 
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: Wicket and Versioning

Posted by "Alexander Adam, Emia Systems" <ad...@emiasys.com>.
Hi,

Thanks a lot, however, doing that for every page seems to be though.
Isn't there a "standard way" in wicket for doing this? I cannot believe such a base case not be covered besides workarounds.. I mean, linking through a Bookmarkable link to my stateful page creates a new version on each click without any changes doesn't make any sense for most applications I think... please, anyone to turn this off? Why does setVersioned have no effect either??

Thanks a bunch!!
Alex

Am 18.07.2012 um 16:38 schrieb Andrea Del Bene:

> Hi,
> 
> you could try with the following solution:
> 
> - Mount a stateless page on your desired path (let's say "/home")
> - This page should do nothing but redirect user to your stateful page, but instead of creating a new instance of it each time, it will save into session your stateful page to use it for the next requests. Its constructor should look like this:
> 
>        Page page = null;
> 
>        if(Session.get().getAttribute("page") == null){
>            Session.get().bind();
>            page = new YourPage();
>            Session.get().setAttribute("page", page);
>        }else{
>            page =(Page) Session.get().getAttribute("page");
>        }
> 
>        setResponsePage(page);
> 
> 
> Inside YourPage you should anyway call serVersioned(false).
>> One more thing --> I don't see any use in versioning in my case: My base page is stateful though that means each and every link I use will lead to a new version number polluting the user's browser history with all the same link even though there has NOTHING changed on the page!? Please, there has to be a way to turn that off.. I was trying to return a PageManager that returns supportsVersioning = false still no effect..
>> 
>> NOTE: I do not want to only get this out of the url but I want to get RID of this feature as it pollutes the session by storing a serialized version of all but the same page...
>> 
>> thanks!!
>> Alex
>> 
>> 
>> Am 18.07.2012 um 14:08 schrieb Josh Kamau:
>> 
>>> Now create something like this
>>> 
>>> public class CleanUrlMapper extends MountedMapper {
>>> 
>>>  public CleanUrlMapper(String mountPath, Class<? extends IRequestablePage>
>>> pageClass) {
>>>    super(mountPath, pageClass, new PageParametersEncoder());
>>>  }
>>> 
>>>  @Override
>>>  protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
>>>    // do nothing so that component info does not get rendered in url
>>>  }
>>> 
>>>  @Override
>>>  public Url mapHandler(IRequestHandler requestHandler)
>>>  {
>>>      if (requestHandler instanceof ListenerInterfaceRequestHandler) {
>>>          return null;
>>>      } else {
>>>           return super.mapHandler(requestHandler);
>>>      }
>>>  }
>>> }
>>> 
>>> and then mount your pages like this
>>> 
>>> mount(new CleanUrlMapper("/home", HomePage.class));
>>> 
>>> 
>>> Atleast thats what i do to achieve something like what you want.
>>> 
>>> Josh.
>>> 
>>> On Wed, Jul 18, 2012 at 2:53 PM, Alexander Adam, Emia Systems <
>>> adam@emiasys.com> wrote:
>>> 
>>>> Hi!
>>>> 
>>>> I am pretty much lost with Wicket 1.5.7 and versioning. What happens is
>>>> this: I've deactivated versioning by setting serVersioned(false) in my
>>>> page's constructor.
>>>> However, still the page id gets increment each time I call the exact same
>>>> url in my browser i.e. home/?0, home/?1, home/?2, etc.
>>>> I simply don't want this behavior, I want to have a stateful page with
>>>> *exactly* one state at a given time for a given user, not more. How can I
>>>> do that?
>>>> I want page refreshes to destroy anything ajax might have created and the
>>>> such still, I want to be stateful to properly use forms, clickable links
>>>> etc..
>>>> 
>>>> please advise, I'm almost giving up :(
>>>> 
>>>> thank you!!
>>>> Alex
>>>> ---------------------------------------------------------------------
>>>> 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: Wicket and Versioning

Posted by Andrea Del Bene <an...@gmail.com>.
Hi,

you could try with the following solution:

- Mount a stateless page on your desired path (let's say "/home")
- This page should do nothing but redirect user to your stateful page, 
but instead of creating a new instance of it each time, it will save 
into session your stateful page to use it for the next requests. Its 
constructor should look like this:

         Page page = null;

         if(Session.get().getAttribute("page") == null){
             Session.get().bind();
             page = new YourPage();
             Session.get().setAttribute("page", page);
         }else{
             page =(Page) Session.get().getAttribute("page");
         }

         setResponsePage(page);


Inside YourPage you should anyway call serVersioned(false).
> One more thing --> I don't see any use in versioning in my case: My base page is stateful though that means each and every link I use will lead to a new version number polluting the user's browser history with all the same link even though there has NOTHING changed on the page!? Please, there has to be a way to turn that off.. I was trying to return a PageManager that returns supportsVersioning = false still no effect..
>
> NOTE: I do not want to only get this out of the url but I want to get RID of this feature as it pollutes the session by storing a serialized version of all but the same page...
>
> thanks!!
> Alex
>
>
> Am 18.07.2012 um 14:08 schrieb Josh Kamau:
>
>> Now create something like this
>>
>> public class CleanUrlMapper extends MountedMapper {
>>
>>   public CleanUrlMapper(String mountPath, Class<? extends IRequestablePage>
>> pageClass) {
>>     super(mountPath, pageClass, new PageParametersEncoder());
>>   }
>>
>>   @Override
>>   protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
>>     // do nothing so that component info does not get rendered in url
>>   }
>>
>>   @Override
>>   public Url mapHandler(IRequestHandler requestHandler)
>>   {
>>       if (requestHandler instanceof ListenerInterfaceRequestHandler) {
>>           return null;
>>       } else {
>>            return super.mapHandler(requestHandler);
>>       }
>>   }
>> }
>>
>> and then mount your pages like this
>>
>> mount(new CleanUrlMapper("/home", HomePage.class));
>>
>>
>> Atleast thats what i do to achieve something like what you want.
>>
>> Josh.
>>
>> On Wed, Jul 18, 2012 at 2:53 PM, Alexander Adam, Emia Systems <
>> adam@emiasys.com> wrote:
>>
>>> Hi!
>>>
>>> I am pretty much lost with Wicket 1.5.7 and versioning. What happens is
>>> this: I've deactivated versioning by setting serVersioned(false) in my
>>> page's constructor.
>>> However, still the page id gets increment each time I call the exact same
>>> url in my browser i.e. home/?0, home/?1, home/?2, etc.
>>> I simply don't want this behavior, I want to have a stateful page with
>>> *exactly* one state at a given time for a given user, not more. How can I
>>> do that?
>>> I want page refreshes to destroy anything ajax might have created and the
>>> such still, I want to be stateful to properly use forms, clickable links
>>> etc..
>>>
>>> please advise, I'm almost giving up :(
>>>
>>> thank you!!
>>> Alex
>>> ---------------------------------------------------------------------
>>> 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: Wicket and Versioning

Posted by "Alexander Adam, Emia Systems" <ad...@emiasys.com>.
One more thing --> I don't see any use in versioning in my case: My base page is stateful though that means each and every link I use will lead to a new version number polluting the user's browser history with all the same link even though there has NOTHING changed on the page!? Please, there has to be a way to turn that off.. I was trying to return a PageManager that returns supportsVersioning = false still no effect..

NOTE: I do not want to only get this out of the url but I want to get RID of this feature as it pollutes the session by storing a serialized version of all but the same page...

thanks!!
Alex


Am 18.07.2012 um 14:08 schrieb Josh Kamau:

> Now create something like this
> 
> public class CleanUrlMapper extends MountedMapper {
> 
>  public CleanUrlMapper(String mountPath, Class<? extends IRequestablePage>
> pageClass) {
>    super(mountPath, pageClass, new PageParametersEncoder());
>  }
> 
>  @Override
>  protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
>    // do nothing so that component info does not get rendered in url
>  }
> 
>  @Override
>  public Url mapHandler(IRequestHandler requestHandler)
>  {
>      if (requestHandler instanceof ListenerInterfaceRequestHandler) {
>          return null;
>      } else {
>           return super.mapHandler(requestHandler);
>      }
>  }
> }
> 
> and then mount your pages like this
> 
> mount(new CleanUrlMapper("/home", HomePage.class));
> 
> 
> Atleast thats what i do to achieve something like what you want.
> 
> Josh.
> 
> On Wed, Jul 18, 2012 at 2:53 PM, Alexander Adam, Emia Systems <
> adam@emiasys.com> wrote:
> 
>> Hi!
>> 
>> I am pretty much lost with Wicket 1.5.7 and versioning. What happens is
>> this: I've deactivated versioning by setting serVersioned(false) in my
>> page's constructor.
>> However, still the page id gets increment each time I call the exact same
>> url in my browser i.e. home/?0, home/?1, home/?2, etc.
>> I simply don't want this behavior, I want to have a stateful page with
>> *exactly* one state at a given time for a given user, not more. How can I
>> do that?
>> I want page refreshes to destroy anything ajax might have created and the
>> such still, I want to be stateful to properly use forms, clickable links
>> etc..
>> 
>> please advise, I'm almost giving up :(
>> 
>> thank you!!
>> Alex
>> ---------------------------------------------------------------------
>> 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: Wicket and Versioning

Posted by "Alexander Adam, Emia Systems" <ad...@emiasys.com>.
thanks! However, this is what I am doing right now, but it gives me heavy troubles on google app engine, for example, handling the submit of forms is working and sometimes is not etc.
Furthermore, I do NOT WANT wicket to save xx versions of the same page in memory or disk for nothing, it should just keep that one version going and that's it.. but all tries to set versioning to false seem to result in.. well no result !?


Alex

> Now create something like this
> 
> public class CleanUrlMapper extends MountedMapper {
> 
>  public CleanUrlMapper(String mountPath, Class<? extends IRequestablePage>
> pageClass) {
>    super(mountPath, pageClass, new PageParametersEncoder());
>  }
> 
>  @Override
>  protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
>    // do nothing so that component info does not get rendered in url
>  }
> 
>  @Override
>  public Url mapHandler(IRequestHandler requestHandler)
>  {
>      if (requestHandler instanceof ListenerInterfaceRequestHandler) {
>          return null;
>      } else {
>           return super.mapHandler(requestHandler);
>      }
>  }
> }
> 
> and then mount your pages like this
> 
> mount(new CleanUrlMapper("/home", HomePage.class));
> 
> 
> Atleast thats what i do to achieve something like what you want.
> 
> Josh.
> 
> On Wed, Jul 18, 2012 at 2:53 PM, Alexander Adam, Emia Systems <
> adam@emiasys.com> wrote:
> 
>> Hi!
>> 
>> I am pretty much lost with Wicket 1.5.7 and versioning. What happens is
>> this: I've deactivated versioning by setting serVersioned(false) in my
>> page's constructor.
>> However, still the page id gets increment each time I call the exact same
>> url in my browser i.e. home/?0, home/?1, home/?2, etc.
>> I simply don't want this behavior, I want to have a stateful page with
>> *exactly* one state at a given time for a given user, not more. How can I
>> do that?
>> I want page refreshes to destroy anything ajax might have created and the
>> such still, I want to be stateful to properly use forms, clickable links
>> etc..
>> 
>> please advise, I'm almost giving up :(
>> 
>> thank you!!
>> Alex
>> ---------------------------------------------------------------------
>> 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: Wicket and Versioning

Posted by Josh Kamau <jo...@gmail.com>.
Now create something like this

public class CleanUrlMapper extends MountedMapper {

  public CleanUrlMapper(String mountPath, Class<? extends IRequestablePage>
pageClass) {
    super(mountPath, pageClass, new PageParametersEncoder());
  }

  @Override
  protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
    // do nothing so that component info does not get rendered in url
  }

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

and then mount your pages like this

 mount(new CleanUrlMapper("/home", HomePage.class));


Atleast thats what i do to achieve something like what you want.

Josh.

On Wed, Jul 18, 2012 at 2:53 PM, Alexander Adam, Emia Systems <
adam@emiasys.com> wrote:

> Hi!
>
> I am pretty much lost with Wicket 1.5.7 and versioning. What happens is
> this: I've deactivated versioning by setting serVersioned(false) in my
> page's constructor.
> However, still the page id gets increment each time I call the exact same
> url in my browser i.e. home/?0, home/?1, home/?2, etc.
> I simply don't want this behavior, I want to have a stateful page with
> *exactly* one state at a given time for a given user, not more. How can I
> do that?
> I want page refreshes to destroy anything ajax might have created and the
> such still, I want to be stateful to properly use forms, clickable links
> etc..
>
> please advise, I'm almost giving up :(
>
> thank you!!
> Alex
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>