Here's a couple of things you can try
-- Use a real logger instead of a Systemout.println to be sure it's
getting into the logs, and log at "error" level or higher.
- Try using t:saveState on a property of a managed bean instead of the
bean itself. I don't think it would matter, but it's a simple thing
to try. For space considerations, I never save a managed bean -- I
only save select properties of the bean.
<t:saveState id="idSaveVideo" value="#{videoHolder.video}"/>
On 4/2/07, lanchez <[EMAIL PROTECTED]> wrote:
I only have a System.out.printlin in my readObject, writeObject. I have
checked all tomcat logs and can not see/find
the print statements.
saveState does not seem to be working as well.
thanks
I
Mike Kienenberger wrote:
>
> It works fine for me.
>
> I have a class of objects that writes additional information using
> writeObject, reads it back in for additional initialization on
> readObject, and even occasionally replaces itself using resolveObject.
>
> Maybe this will help you find the problem.
>
> private void writeObject(java.io.ObjectOutputStream out)
> throws IOException
> {
> Logger logger = Logger.getLogger("serialization");
> if (null == this.getDataContext())
> {
> logger.info("writeObject: " + this.getClass().getName() + "
> [" + String.valueOf(this.hashCode()) + "] has no DC.");
> logger.info("writeObject: " + this);
> Thread.dumpStack();
> }
> out.writeBoolean(Boolean.TRUE ==
> this.getDataContext().getUserProperty("temporary"));
> out.defaultWriteObject();
>
> if (Boolean.TRUE ==
> this.getDataContext().getUserProperty("temporary"))
> {
> logger.info("writeObject: " + this.getClass().getName() + "
> [" + String.valueOf(this.hashCode()) + "] has DC [" +
> String.valueOf(this.getDataContext().hashCode()) + "] and is marked
> temporary.");
> }
> else
> {
> logger.info("writeObject: " + this.getClass().getName() + "
> [" + String.valueOf(this.hashCode()) + "] has DC [" +
> String.valueOf(this.getDataContext().hashCode()) + "] and is not
> marked temporary.");
> }
> }
>
> private void readObject(java.io.ObjectInputStream in)
> throws IOException, ClassNotFoundException
> {
> boolean isInTemporaryDataContext = in.readBoolean();
> in.defaultReadObject();
> this.isInTemporaryDataContext = isInTemporaryDataContext;
>
> Logger logger = Logger.getLogger("serialization");
> if (null != this.getDataContext())
> {
> if (isInTemporaryDataContext)
> {
> logger.info("readObject: " + this.getClass().getName() +
> " [" + String.valueOf(this.hashCode()) + "] has DC [" +
> String.valueOf(this.getDataContext().hashCode()) + "] and is marked
> temporary.");
> }
> else
> {
> logger.info("readObject: " + this.getClass().getName() +
> " [" + String.valueOf(this.hashCode()) + "] has DC [" +
> String.valueOf(this.getDataContext().hashCode()) + "] and is not
> marked temporary.");
> }
> }
> else
> {
> if (isInTemporaryDataContext)
> {
> logger.info("readObject: " + this.getClass().getName() +
> " [" + String.valueOf(this.hashCode()) + "] has no DC and is marked
> temporary.");
> }
> else
> {
> logger.info("readObject: " + this.getClass().getName() +
> " [" + String.valueOf(this.hashCode()) + "] has no DC and is not
> marked temporary.");
> }
> }
> }
> /**
> * Substitute self with an object registered in thread
> * DataContext with the same ID.
> */
> protected Object readResolve() throws ObjectStreamException
> {
> if (null == getDataContext())
> {
> if (isInTemporaryDataContext)
> {
> Logger logger = Logger.getLogger("serialization");
> logger.info("readResolve: " + this.getClass().getName() +
> " [" + String.valueOf(this.hashCode()) + "] has no DC and is marked
> temporary.");
>
> return this;
> }
> else
> {
> Logger logger = Logger.getLogger("serialization");
> logger.info("readResolve: " + this.getClass().getName() +
> " [" + String.valueOf(this.hashCode()) + "] has no DC and is not
> marked temporary.");
>
> DataContext context;
>
> try {
> context = DataContext.getThreadDataContext();
> }
> catch (IllegalStateException e) {
> throw new NotActiveException("Can't deserialize
> object for id '"
> + getObjectId()
> + "' - no DataContext bound to thread.");
> }
>
> // return context.registeredObject(getObjectId());
> return context.localObject(getObjectId(), null);
> }
> }
> else
> {
> Logger logger = Logger.getLogger("serialization");
> logger.info("readResolve: " + this.getClass().getName() + "
> [" + String.valueOf(this.hashCode()) + "] has DC [" +
> String.valueOf(this.getDataContext().hashCode()) + "].");
> return this;
> }
> }
>
>
>
> On 4/2/07, I Faces <[EMAIL PROTECTED]> wrote:
>>
>> I have an xhtml page with t:saveState references a backing bean. The
>> backing
>> bean is serializable and I have two methods private void readObject,
>> private
>> void writeObject however neither of these get called.
>>
>> As I understand it these methods should get called when an object is
>> serialized. Is there something wrong with the JSF implementation of
>> saveState such that these methods do not get called as they should?
>>
>> How do I verify that saveState is working correctly? After stepping
>> through
>> the code, doe not look like the <t:saveState does anything at all.
>>
>> thanks for your help
>>
>>
>> I
>> --
>> View this message in context:
>>
http://www.nabble.com/%3Ct%3AsaveState%3E-not-working---not-serializing-correctly.-tf3507948.html#a9797927
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/%3Ct%3AsaveState%3E-not-working---not-serializing-correctly.-tf3507948.html#a9802307
Sent from the MyFaces - Users mailing list archive at Nabble.com.