Agreed. And I could actually think of cases where I'd want to use it myself.

Eelco

Phil Kulak wrote:

Yea, turing everything into a POST is definatly where the work is.
I've got it working right now with a subclass of Form that writes the
hidden field, but everything has to be a button for it to work.

I agree that for most applications, storing all the state on the
client is not the way to go. And honestly, I wouldn't use it if it
were an option. But, it would remove just about the only excuse people
have not to use Wicket at this point. Plus, .NET and JSF use this
pattern, so someone thinks it's a good idea.

-Phil

On 7/1/05, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
Nevertheless, there have been discussions about this feature on and off,
and though we decided not to implement it in 1.0, we should do so (as an
option) for 1.1. It is also a part of the 'stateless' thing we have been
talking about.

Eelco

Johan Compagner wrote:

still don't see that mail!

For back button support we don't really need this. I find the current
back button support good enough.

Maybe if a session invalidates on the server because the user did have
a koffie break, we could restore it\
But i would say set the session time out on 12 hours or so.. (and
invalidate the session when they log out or something like that)
And a server should just dump session that aren't used for a specific
time to disk...
So that when the request comes back then the server can read it in.

I only don't know if servers are doing that. So maybe we could do it.

Besides that if you have really only client side state and we
constantly construct everything again. Then we are creating lots of
garbage.
And that is just an area where i have seen a lot of problems (if load
is high or large heaps)

The best thing in my eyes would be long session time outs and the
server is just storing old onces (not used for X minutes) to disk...

johan




Eelco Hillenius wrote:

Ah, missed this email. Where does PageState go in the whole?.

Eelco


Phil Kulak wrote:

Here's a proof of concept I just wipped up. It seems to work just
fine. The only problem is that turning everything into a post may be a
bit tricky and is probably where all the work is.

-Phil

On 6/30/05, Phil Kulak <[EMAIL PROTECTED]> wrote:


There has been some mention of this, but I've never heard of the
details. Is this something that's planned? I've been thinking about
it, and it may not actually be that bad. All you'd have to do is
serialize all the models under a page into a base64 string (or
equivelent), then plunk them all back into a fresh component tree on
the next request: pretty much how .NET and JSF do it. That would solve
all the back-button issues, you could get a totally stateless
webserver AND have the killer wicket component model. Anyway, just
some thoughs. I'm going to play around with it and probably figure out
that it's a lot more complicated then that in the process. :)


------------------------------------------------------------------------


package com.apropobenefits.wicket;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

import org.apache.commons.codec.binary.Base64;

import wicket.Component;
import wicket.Page;
import wicket.WicketRuntimeException;
import wicket.Component.IVisitor;
import wicket.model.IModel;

public class PageState {
   private Map<String, IModel> models;
       /**
    * Creates a new PageState from the given page.
    */
   public PageState(Page page) {
       models = new HashMap<String, IModel>();
              // Add the page model.
       IModel pageModel = page.getModel();
       if (pageModel != null) {
           models.put("", pageModel);
       }
              page.visitChildren(new IVisitor() {
           public Object component(Component component) {
               IModel model = component.getModel();
               if (model != null) {
                   models.put(component.getPageRelativePath(),
model);
               }
               return CONTINUE_TRAVERSAL;
           }
       });
   }
       /**
    * Creates a new PageState from a string.
    */
   public PageState(String serializedString) {
       ByteArrayInputStream bais = null;
       GZIPInputStream unzipper = null;
       ObjectInputStream in = null;
              try {
           bais = new ByteArrayInputStream(
               Base64.decodeBase64(serializedString.getBytes()));
           unzipper = new GZIPInputStream(bais);
           in = new ObjectInputStream(unzipper);
           models = (Map<String, IModel>) in.readObject();
           in.close();
       } catch (Exception e) {
           throw new WicketRuntimeException(e.getMessage());
       }
   }
       /**
    * Returns a base64 string that can be used to store the page
state
    * on the client.
    */
   public String getString() {
       ByteArrayOutputStream baos = null;
       GZIPOutputStream zipper = null;
       ObjectOutputStream out = null;
              // Detach all the models.
       for (IModel model: models.values()) {
           model.detach();
       }
              try {
           baos = new ByteArrayOutputStream();
           zipper = new GZIPOutputStream(baos);
           out = new ObjectOutputStream(zipper);
           out.writeObject(models);
           out.close();
       } catch (Exception e) {
           throw new WicketRuntimeException(e.getMessage());
       }

       return new
String(Base64.encodeBase64Chunked(baos.toByteArray()));
   }
       /**
    * Returns the page to the state represented by this page state.
    */
   public void populatePage(Page page) {
       if (models.containsKey("")) {
           page.setModel(models.get(""));
       }
              page.visitChildren(new IVisitor() {
           public Object component(Component component) {
               String path = component.getPageRelativePath();
               if (models.containsKey(path)) {
                   component.setModel(models.get(path));
               }
               return CONTINUE_TRAVERSAL;
           }
       });
   }
}


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to