Hi!
> With client state saving, I was under the impression that only managed
> beans in session scope or used in t:saveState would be serialized into
> the hidden javax.faces.ViewState variable.  However, my application's
> creating ViewStates in pages with very simple forms that are almost 70
> kb long!
I've create a simple ViewState dumper which allows you to .. well ...
dump the view state :-) ... as long as you do not compression or encryption.
Just set the viewState variable to the content of the viewState in the
HTML output.
Maybe you can figure out what happens.

Unhappily there is no information about which component added the data
to the state, though, it might be a start anyway.


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

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.Collection;

public class ViewStateDumper
{
    public static void main(String[] args) throws IOException,
ClassNotFoundException
    {
        String viewState="";

        byte[] viewStateData =
Base64.decodeBase64(viewState.getBytes("US-ASCII"));
        ObjectInputStream ois = new ObjectInputStream(new
ByteArrayInputStream(viewStateData));

        Object[] state = (Object[]) ois.readObject();
        dumpState("", state);
    }

    private static void dumpState(String prefix, Object[] state)
    {
        for (Object object : state)
        {
            System.err.print(prefix);

            if (object == null)
            {
                System.err.println("#null?");
            }
            else if (object instanceof Object[])
            {
                System.err.println(prefix + "array");
                dumpState(prefix + "    ", (Object[]) object);
            }
            else if (object instanceof Collection)
            {
                System.err.println(prefix + "collection");
                dumpState(prefix + "    ", ((Collection) object).toArray());
            }
            else
            {
                System.err.print(object.getClass().getName());
                System.err.print(" ");
                System.err.println(object.toString());
            }
        }
    }
}


Ciao,
Mario

Reply via email to