myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ken McArthur" <ken.mcart...@adsea.com>
Subject Re: javax.faces.ViewState contents?
Date Fri, 24 Aug 2007 00:12:58 GMT
Mario,

ViewStateDumper is awesome!  I get a large number of "#null?"s in output but
everything else is as expected.  In my situation bottleneck is bandwidth;
especially since ViewState is sent back to server and upload speeds are most
always much slower than download speeds.  Compressed ViewState by adding the
following to web.xml:

  <context-param>
    <param-name>org.apache.myfaces.COMPRESS_STATE_IN_CLIENT</param-name>
    <param-value>true</param-value>
  </context-param>

This cut ViewState down by about 1/5th.

Thanks again to all.  I think I have good temporary solution but will look
more into server side state saving.

Ken




On 8/23/07, Ken McArthur <ken.mcarthur@adsea.com> wrote:
>
> Great advise, I'll try it all and update board when I figure it out.
> Thanks.
>
> On 8/23/07, Mario Ivankovits <mario@ops.co.at > wrote:
> >
> > 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
> >
> >
>
>
> --
> 303-619-6607
> http://adsea.com
>



-- 
303-619-6607
http://adsea.com

Mime
View raw message