You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by support <ap...@purpleblade.net> on 2007/01/12 03:44:06 UTC
problems (not working / have tried everything)
How would I know if my <t:saveState> is working or not (by looking at
physical files)?
I set STATE_SAVING_METHOD to "client" in my web.xml and supposed I would
see something in the source html file. My saveState looked like this:
<t:saveState id="idSaveObject" value="${object}"
I searched in the html source (in browser) looking for "idSaveObject"
and saw nothing. If SAVE_STATE_METHOD is "client" where (what file) can
I verify that saveState is working?
---
I then set SAVE_STATE_METHOD to "server" and made my BB implement
serializable and searched under the <TOMCAT_ROOT>/work/ directory for
*.ser and looked at each file but saw nothing. I supposed that
SAVE_STATE_METHOD "sever" means that it serialized the BB, but saw
nothing that indicated the BB had been serialized. Am I looking in the
right place for Tomcat.
---
How do I tell for sure if <t:saveState> is working and what could be the
problem?
thanks
Simon
Re: problems (not working / have tried everything)
Posted by Lisa <ap...@purpleblade.net>.
I am sure this is working and it mostly works for me, but I have one
situation where it appears to work then stops working for some reason. I
simply can not figure this out.
Simon Kitching-3 wrote:
>
> SimonSays wrote:
>> So why is it that I read if you use <t:saveState> that the BB must
>> implement
>> Serializable? So something that is serializable does not necessarily
>> write
>> out a file system file, but can store the file in memory as well?
>
> There are three options for saving a component tree:
> (a) serialize it and send it to the client browser as a hidden input field
> (b) serialize it and store it into the webserver's http session
> (c) store it into the webserver's http session unserialized.
>
> For (a) and (b), the object being saved must implement
> java.io.Serializable, or javax.faces.component.StateHolder.
>
> Option (c) is easier, but doesn't work with clustering, doesn't support
> "hot restart" and doesn't allow the webserver to store a user's http
> session on disk when memory gets short. It is therefore not the default;
> you need to explicitly enable this mode (and I wouldn't recommend it).
>
>>
>> Also if STATE_SAVING_METHOD set to "server" saves a "file" the the
>> HttpSession what does STATE_SAVING_METHOD set to "client" do differently?
>
> MyFaces never "saves a file". It just places an object (which may be a
> serialized object [b], or an unserialized one [c]) into the http
> session. What the webserver does with a user's http session is up to it.
>
> You may need to read about serialization; it is NOT just about writing
> data to files on a disk.
>
>>
>> how do I tell if the whole object is being serialized (state saved)
>> rather
>> than just some property in a bean? I may hit the breakpoints but I want
>> to
>> see the actual data somewhere and watch it get restored as well. I do
>> not
>> believe <t:saveState> is working but do not know why. I need to know for
>> sure that it is not working before I go and try to find out why.
>
> I can't think of any easy way to do this. Java serialization is pretty
> complex, and not the sort of thing I would want to trace through. Maybe
> you could define your own readObject/writeObject methods that just
> delegate to the standard implementations to give yourself somewhere to
> place your breakpoints but I've never needed to do that.
>
> I assure you that t:saveState does work for many thousands of other
> people out there (including myself).
>
> Regards,
>
> Simon
>
>
--
View this message in context: http://www.nabble.com/%3Ct%3AsaveState%3E-problems-%28not-working---have-tried-everything%29-tf2963422.html#a8367352
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: problems (not working / have tried everything)
Posted by Lisa <ap...@purpleblade.net>.
I put two methods in my BB that I understand should be called during the
serialization/deserialization process that <t:saveState> invokes.
I do not see in my Tomcat log that these two methods are being called. Does
this mean that <t:saveState> is indeed not working in my case?
The methods I put in my BB that the xhtml references (which contains
<t:saveState> are as follows:
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
System.out.println("--- Deserialization (saveState):
PtGroupAdmin.readObject() ---");
}
private void writeObject(ObjectOutputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultWriteObject();
System.out.println("--- Serialization (saveState):
PtGroupAdmin.writeObject() ---");
}
The fact that neither of these are called in my BB indicate that
<t:saveState> (for some reason) is not working in my project. I am sure it
works, but there may be some odd reason (config) it is not working here.
Any help would be appreciated. I inherited this framework and am trying to
find out if it works like people think that it is. Would putting these two
methods in my BB be in indication that the <t:saveState> and Serrialization
are working correctly or am I on the wrong path?
Simon Kitching-3 wrote:
>
> SimonSays wrote:
>> So why is it that I read if you use <t:saveState> that the BB must
>> implement
>> Serializable? So something that is serializable does not necessarily
>> write
>> out a file system file, but can store the file in memory as well?
>
> There are three options for saving a component tree:
> (a) serialize it and send it to the client browser as a hidden input field
> (b) serialize it and store it into the webserver's http session
> (c) store it into the webserver's http session unserialized.
>
> For (a) and (b), the object being saved must implement
> java.io.Serializable, or javax.faces.component.StateHolder.
>
> Option (c) is easier, but doesn't work with clustering, doesn't support
> "hot restart" and doesn't allow the webserver to store a user's http
> session on disk when memory gets short. It is therefore not the default;
> you need to explicitly enable this mode (and I wouldn't recommend it).
>
>>
>> Also if STATE_SAVING_METHOD set to "server" saves a "file" the the
>> HttpSession what does STATE_SAVING_METHOD set to "client" do differently?
>
> MyFaces never "saves a file". It just places an object (which may be a
> serialized object [b], or an unserialized one [c]) into the http
> session. What the webserver does with a user's http session is up to it.
>
> You may need to read about serialization; it is NOT just about writing
> data to files on a disk.
>
>>
>> how do I tell if the whole object is being serialized (state saved)
>> rather
>> than just some property in a bean? I may hit the breakpoints but I want
>> to
>> see the actual data somewhere and watch it get restored as well. I do
>> not
>> believe <t:saveState> is working but do not know why. I need to know for
>> sure that it is not working before I go and try to find out why.
>
> I can't think of any easy way to do this. Java serialization is pretty
> complex, and not the sort of thing I would want to trace through. Maybe
> you could define your own readObject/writeObject methods that just
> delegate to the standard implementations to give yourself somewhere to
> place your breakpoints but I've never needed to do that.
>
> I assure you that t:saveState does work for many thousands of other
> people out there (including myself).
>
> Regards,
>
> Simon
>
>
--
View this message in context: http://www.nabble.com/%3Ct%3AsaveState%3E-problems-%28not-working---have-tried-everything%29-tf2963422.html#a8377572
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: problems (not working / have tried everything)
Posted by Simon Kitching <si...@rhe.co.nz>.
SimonSays wrote:
> So why is it that I read if you use <t:saveState> that the BB must implement
> Serializable? So something that is serializable does not necessarily write
> out a file system file, but can store the file in memory as well?
There are three options for saving a component tree:
(a) serialize it and send it to the client browser as a hidden input field
(b) serialize it and store it into the webserver's http session
(c) store it into the webserver's http session unserialized.
For (a) and (b), the object being saved must implement
java.io.Serializable, or javax.faces.component.StateHolder.
Option (c) is easier, but doesn't work with clustering, doesn't support
"hot restart" and doesn't allow the webserver to store a user's http
session on disk when memory gets short. It is therefore not the default;
you need to explicitly enable this mode (and I wouldn't recommend it).
>
> Also if STATE_SAVING_METHOD set to "server" saves a "file" the the
> HttpSession what does STATE_SAVING_METHOD set to "client" do differently?
MyFaces never "saves a file". It just places an object (which may be a
serialized object [b], or an unserialized one [c]) into the http
session. What the webserver does with a user's http session is up to it.
You may need to read about serialization; it is NOT just about writing
data to files on a disk.
>
> how do I tell if the whole object is being serialized (state saved) rather
> than just some property in a bean? I may hit the breakpoints but I want to
> see the actual data somewhere and watch it get restored as well. I do not
> believe <t:saveState> is working but do not know why. I need to know for
> sure that it is not working before I go and try to find out why.
I can't think of any easy way to do this. Java serialization is pretty
complex, and not the sort of thing I would want to trace through. Maybe
you could define your own readObject/writeObject methods that just
delegate to the standard implementations to give yourself somewhere to
place your breakpoints but I've never needed to do that.
I assure you that t:saveState does work for many thousands of other
people out there (including myself).
Regards,
Simon
Re: problems (not working / have tried everything)
Posted by SimonSays <ap...@purpleblade.net>.
So why is it that I read if you use <t:saveState> that the BB must implement
Serializable? So something that is serializable does not necessarily write
out a file system file, but can store the file in memory as well?
Also if STATE_SAVING_METHOD set to "server" saves a "file" the the
HttpSession what does STATE_SAVING_METHOD set to "client" do differently?
how do I tell if the whole object is being serialized (state saved) rather
than just some property in a bean? I may hit the breakpoints but I want to
see the actual data somewhere and watch it get restored as well. I do not
believe <t:saveState> is working but do not know why. I need to know for
sure that it is not working before I go and try to find out why.
Thanks
Simon
Simon Kitching-3 wrote:
>
> support wrote:
>> How would I know if my <t:saveState> is working or not (by looking at
>> physical files)?
>>
>> I set STATE_SAVING_METHOD to "client" in my web.xml and supposed I would
>> see something in the source html file. My saveState looked like this:
>> <t:saveState id="idSaveObject" value="${object}"
>>
>> I searched in the html source (in browser) looking for "idSaveObject"
>> and saw nothing. If SAVE_STATE_METHOD is "client" where (what file) can
>> I verify that saveState is working?
>
>
> You won't be able to tell from inspecting the html. There will be a
> field called "jtree_64" or something like that (can't remember the exact
> name), with a big long hex string in it (like "ABCD12345......"). This
> is the base64-encoded representation of the entire component string, and
> you would have to decode that to see what is stored. Believe me, you do
> not want to do that.
>
>>
>> ---
>> I then set SAVE_STATE_METHOD to "server" and made my BB implement
>> serializable and searched under the <TOMCAT_ROOT>/work/ directory for
>> *.ser and looked at each file but saw nothing. I supposed that
>> SAVE_STATE_METHOD "sever" means that it serialized the BB, but saw
>> nothing that indicated the BB had been serialized. Am I looking in the
>> right place for Tomcat.
>
> It serializes the entire component tree, and stores it into the http
> session. This typically exists only in memory, though if the webserver
> finds itself short of memory it might start saving http sessions to
> disk. You really won't want to go hunting through those though.
>
>>
>> ---
>> How do I tell for sure if <t:saveState> is working and what could be the
>> problem?
>
> Add a breakpoint, or some logging, on the get/set methods you point the
> t:saveState component to. eg if you have
> <t:saveState value="#someBean.someObject"/>
> then add logging or breakpoints to methods
> getSomeObject
> and
> setSomeObject.
>
> The get will be called during the rendering phase, and the set will be
> called during the restore-view phase.
>
> Regards,
>
> Simon
>
>
--
View this message in context: http://www.nabble.com/%3Ct%3AsaveState%3E-problems-%28not-working---have-tried-everything%29-tf2963422.html#a8292733
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: problems (not working / have tried everything)
Posted by Simon Kitching <si...@rhe.co.nz>.
support wrote:
> How would I know if my <t:saveState> is working or not (by looking at
> physical files)?
>
> I set STATE_SAVING_METHOD to "client" in my web.xml and supposed I would
> see something in the source html file. My saveState looked like this:
> <t:saveState id="idSaveObject" value="${object}"
>
> I searched in the html source (in browser) looking for "idSaveObject"
> and saw nothing. If SAVE_STATE_METHOD is "client" where (what file) can
> I verify that saveState is working?
You won't be able to tell from inspecting the html. There will be a
field called "jtree_64" or something like that (can't remember the exact
name), with a big long hex string in it (like "ABCD12345......"). This
is the base64-encoded representation of the entire component string, and
you would have to decode that to see what is stored. Believe me, you do
not want to do that.
>
> ---
> I then set SAVE_STATE_METHOD to "server" and made my BB implement
> serializable and searched under the <TOMCAT_ROOT>/work/ directory for
> *.ser and looked at each file but saw nothing. I supposed that
> SAVE_STATE_METHOD "sever" means that it serialized the BB, but saw
> nothing that indicated the BB had been serialized. Am I looking in the
> right place for Tomcat.
It serializes the entire component tree, and stores it into the http
session. This typically exists only in memory, though if the webserver
finds itself short of memory it might start saving http sessions to
disk. You really won't want to go hunting through those though.
>
> ---
> How do I tell for sure if <t:saveState> is working and what could be the
> problem?
Add a breakpoint, or some logging, on the get/set methods you point the
t:saveState component to. eg if you have
<t:saveState value="#someBean.someObject"/>
then add logging or breakpoints to methods
getSomeObject
and
setSomeObject.
The get will be called during the rendering phase, and the set will be
called during the restore-view phase.
Regards,
Simon