I'd like to encode simple state objects in the history token as a
general way to interact with the back button, manage application state
etc. For example, the "search string" and "current page" could be
properties on the state object.

See the code below. I can't get it to work, because this is not how it
should be done in GWT (appearantly).

I get:
"The constructor String(byte[]) is undefined"
and
" The method getBytes(String) is undefined for the type String"

Any help with this is greatly appreciated. How to do this properly?

******************************************************************************************************

        // serialize a MyObject as a history token
        private static String toHistoryToken( MyObject o ) throws IOException
{

                ByteArrayOutputStream baStream = new ByteArrayOutputStream();
                ObjectOutputStream oStream = new ObjectOutputStream( baStream );

                oStream.writeObject( o );
                return new String( baStream.toByteArray() );
        }
        // de-serialize a history token to a MyObject
        private static MyObject toObject( String s ) throws IOException,
ClassNotFoundException{

                ByteArrayInputStream baStream = new ByteArrayInputStream( 
s.getBytes
() );
                ObjectInputStream oStream = new ObjectInputStream( baStream );

                return (MyObject) oStream.readObject();
        }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to