You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Lisa <ap...@purpleblade.net> on 2007/02/06 00:21:53 UTC

When does saveState occur?

If I have <t:saveState> in my bean.  On a managed bean, when does saveState
(restoring of values) actually occur?

1.  before the setters listed in the managed-bean?
2.  Immediately after the setters in the managed bean?
3.  Some other time?

thanks


L
-- 
View this message in context: http://www.nabble.com/When-does-saveState-occur--tf3177625.html#a8817361
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: When does saveState occur?

Posted by Werner Punz <we...@gmx.at>.
Werner Punz schrieb:
> Lisa schrieb:
>> If I have <t:saveState> in my bean.  On a managed bean, when does saveState
>> (restoring of values) actually occur?
>>
>> 1.  before the setters listed in the managed-bean?
>> 2.  Immediately after the setters in the managed bean?
>> 3.  Some other time?
>>
> Pretty much at the and of the lifecycle.
> 
> the restore happens at the beginning.
> So the values are first restored, then the request values are applied
> after that all the work is done in the other phase, then it is saved again.
> 
> 
sorry I meant phases, not phase ;-)
I should have gone to bed already


Re: When does saveState occur?

Posted by Werner Punz <we...@gmail.com>.
Ok we are getting close
do you use some kind of managed bean
spring binding layer?
if yes which one?

Try to declare your address bean also in
spring and not in jsf, if you
do a mixed binding of spring
and jsf beans you often
can run into problems especially
with object assignments.

Also:
Have in mind that following happens

at saveing
all the entire object content is
serialized via standard java serialisation mechanisms
into a data structure internally (byte[] most likely, I cannot
remember it has been a while)
so if something within this serialisation fails
saveState does not work (it normally should throw an exception somewhere)

which means if you have an entire object cascade referenced
at that time, make sure that the more complex non serialisable
objects are set to transient otherwise saving will fail.

Whatever can be serialised and also is declared within as a bean
should be serializable.

Werner


Lisa schrieb:
> no, just Java types, String, boolean.  Other objects needed are singletons
> managed/injected by Spring.
> 
> thanks


Re: When does saveState occur?

Posted by Werner Punz <we...@gmail.com>.
Lisa, there is an extensive example for the saveState tag in the sandbox
examples:
http://www.irian.at/myfaces-sandbox/home.jsf

check out scopeShop1

this example basically implements an order form wizard via saveState
tags compare that one to your code.

(if you need a prebuilt war of the current sandbox examples, I did some
fixing, and left a war on my local server at home:

http://wuerg.kicks-ass.net:8080/webdav

I hope this helps you a little bit



Lisa schrieb:
> no, just Java types, String, boolean.  Other objects needed are singletons
> managed/injected by Spring.
> 
> thanks
> 
> L
> 
> 
> Werner Punz-2 wrote:
>> Lisa schrieb:
>>> I'm not seeing that the values are restored at the beginning.  I must
>>> have
>>> something wrong.
>>>
>>> I have a BB that has 3 setters called after instantiation.  I need the
>>> saveState restore to happen before these setters are called but it looks
>>> like the values are being restored much later.
>>>
>>> Is there a way to have the state restored before the setters are called?
>>>
>>> thanks
>>>
>>> L
>>>
>> Lisa is there something in your referenced bean in t:saveState which is
>> not serializable, complex values which are put into savestate are
>> serialized.
>>
>>
>>
> 


Re: When does saveState occur?

Posted by Lisa <ap...@purpleblade.net>.
no, just Java types, String, boolean.  Other objects needed are singletons
managed/injected by Spring.

thanks

L


Werner Punz-2 wrote:
> 
> Lisa schrieb:
>> I'm not seeing that the values are restored at the beginning.  I must
>> have
>> something wrong.
>> 
>> I have a BB that has 3 setters called after instantiation.  I need the
>> saveState restore to happen before these setters are called but it looks
>> like the values are being restored much later.
>> 
>> Is there a way to have the state restored before the setters are called?
>> 
>> thanks
>> 
>> L
>> 
> Lisa is there something in your referenced bean in t:saveState which is
> not serializable, complex values which are put into savestate are
> serialized.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/When-does-saveState-occur--tf3177625.html#a8835075
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: When does saveState occur?

Posted by Werner Punz <we...@gmail.com>.
Lisa schrieb:
> I'm not seeing that the values are restored at the beginning.  I must have
> something wrong.
> 
> I have a BB that has 3 setters called after instantiation.  I need the
> saveState restore to happen before these setters are called but it looks
> like the values are being restored much later.
> 
> Is there a way to have the state restored before the setters are called?
> 
> thanks
> 
> L
> 
Lisa is there something in your referenced bean in t:saveState which is
not serializable, complex values which are put into savestate are
serialized.


Re: When does saveState occur?

Posted by Werner Punz <we...@gmail.com>.
Lisa, is address definitely serializable?


Lisa schrieb:
> The <t:saveState> looks like this:
> 
> <t:saveState id="idSaveAddress" value="#{address}"/>
> 
> ---
> JSF config file (for this managed bean) looks like this:
> 
> ---
>    <managed-bean>
>         <managed-bean-name>address</managed-bean-name>
>         <managed-bean-class>com.disney.bb.address</managed-bean-class>
>         <managed-bean-scope>request</managed-bean-scope>
>     </managed-bean>
> ---
> 
> Will write a test case so I can actually see the values during during
> instantiation (constructor), during setters and just after the setters.
> 
> thanks
> 
> L
> 
> 
> 
> Simon Kitching-3 wrote:
>> Lisa wrote:
>>> I'm not seeing that the values are restored at the beginning.  I must
>>> have
>>> something wrong.
>>>
>>> I have a BB that has 3 setters called after instantiation.  I need the
>>> saveState restore to happen before these setters are called but it looks
>>> like the values are being restored much later.
>>>
>>> Is there a way to have the state restored before the setters are called?
>> The t:saveState bean does its work in the restore-view phase. It will 
>> therefore definitely happen before any value-binding expressions on JSF 
>> components are evaluated.
>>
>> If you are seeing normal setters called during the "update model" phase 
>> but t:saveState hasn't executed to restore the saved data then you have 
>> something set up wrong - ie t:saveState is not being processed at all, 
>> or is updating some variable other than the one you are expecting.
>>
>> Are you definitely setting the value attribute to a 
>> value-binding-expression, ie
>>    <t:saveState value="#{myBean}"/>
>> not
>>    <t:saveState value="myBean"/>
>> ?
>>
>> Regards,
>>
>> Simon
>>
>>
> 


Re: When does saveState occur?

Posted by Lisa <ap...@purpleblade.net>.
The <t:saveState> looks like this:

<t:saveState id="idSaveAddress" value="#{address}"/>

---
JSF config file (for this managed bean) looks like this:

---
   <managed-bean>
        <managed-bean-name>address</managed-bean-name>
        <managed-bean-class>com.disney.bb.address</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
---

Will write a test case so I can actually see the values during during
instantiation (constructor), during setters and just after the setters.

thanks

L



Simon Kitching-3 wrote:
> 
> Lisa wrote:
>> I'm not seeing that the values are restored at the beginning.  I must
>> have
>> something wrong.
>> 
>> I have a BB that has 3 setters called after instantiation.  I need the
>> saveState restore to happen before these setters are called but it looks
>> like the values are being restored much later.
>> 
>> Is there a way to have the state restored before the setters are called?
> 
> The t:saveState bean does its work in the restore-view phase. It will 
> therefore definitely happen before any value-binding expressions on JSF 
> components are evaluated.
> 
> If you are seeing normal setters called during the "update model" phase 
> but t:saveState hasn't executed to restore the saved data then you have 
> something set up wrong - ie t:saveState is not being processed at all, 
> or is updating some variable other than the one you are expecting.
> 
> Are you definitely setting the value attribute to a 
> value-binding-expression, ie
>    <t:saveState value="#{myBean}"/>
> not
>    <t:saveState value="myBean"/>
> ?
> 
> Regards,
> 
> Simon
> 
> 

-- 
View this message in context: http://www.nabble.com/When-does-saveState-occur--tf3177625.html#a8835162
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: When does saveState occur?

Posted by Simon Kitching <si...@rhe.co.nz>.
Lisa wrote:
> I'm not seeing that the values are restored at the beginning.  I must have
> something wrong.
> 
> I have a BB that has 3 setters called after instantiation.  I need the
> saveState restore to happen before these setters are called but it looks
> like the values are being restored much later.
> 
> Is there a way to have the state restored before the setters are called?

The t:saveState bean does its work in the restore-view phase. It will 
therefore definitely happen before any value-binding expressions on JSF 
components are evaluated.

If you are seeing normal setters called during the "update model" phase 
but t:saveState hasn't executed to restore the saved data then you have 
something set up wrong - ie t:saveState is not being processed at all, 
or is updating some variable other than the one you are expecting.

Are you definitely setting the value attribute to a 
value-binding-expression, ie
   <t:saveState value="#{myBean}"/>
not
   <t:saveState value="myBean"/>
?

Regards,

Simon

Re: When does saveState occur?

Posted by Lisa <ap...@purpleblade.net>.
I'm not seeing that the values are restored at the beginning.  I must have
something wrong.

I have a BB that has 3 setters called after instantiation.  I need the
saveState restore to happen before these setters are called but it looks
like the values are being restored much later.

Is there a way to have the state restored before the setters are called?

thanks

L


Werner Punz wrote:
> 
> Lisa schrieb:
>> If I have <t:saveState> in my bean.  On a managed bean, when does
>> saveState
>> (restoring of values) actually occur?
>> 
>> 1.  before the setters listed in the managed-bean?
>> 2.  Immediately after the setters in the managed bean?
>> 3.  Some other time?
>> 
> Pretty much at the and of the lifecycle.
> 
> the restore happens at the beginning.
> So the values are first restored, then the request values are applied
> after that all the work is done in the other phase, then it is saved
> again.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/When-does-saveState-occur--tf3177625.html#a8820377
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: When does saveState occur?

Posted by Werner Punz <we...@gmx.at>.
Lisa schrieb:
> If I have <t:saveState> in my bean.  On a managed bean, when does saveState
> (restoring of values) actually occur?
> 
> 1.  before the setters listed in the managed-bean?
> 2.  Immediately after the setters in the managed bean?
> 3.  Some other time?
> 
Pretty much at the and of the lifecycle.

the restore happens at the beginning.
So the values are first restored, then the request values are applied
after that all the work is done in the other phase, then it is saved again.