You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by John Ruffin <jr...@achfood.com> on 2006/04/28 03:13:13 UTC

t:saveState how-to?

I want users to flow through say 2 screens then I want to save their
submitted data.  I use t:saveState to keep the data around. 

I added: <t:saveState id="saveHierachy" value="#{parentForm}"/> to the first
form and <t:saveState id="saveHierachy" value="#{divisionForm}"/> in the
second form.  Both beans implement Serializable.  <t:saveState> is outside
<f:view>. javax.faces.STATE_SAVING_METHOD is set to client.

This works ok if I only want to display data on screen. (i.e. I can display
data submitted in parentForm.jsp on divisionForm.jsp.  But I want to save
when divisionForm is submitted.

So, I created a managed-bean of type Parent (a domain class) - called
baseParent like this:

	<managed-bean>
		<managed-bean-name>baseParent</managed-bean-name>
		<managed-bean-class>com.jruffin.model.Parent</managed-bean-class>
		<managed-bean-scope>request</managed-bean-scope>
	</managed-bean>

This gets injected into divisionForm like this:
        <managed-bean>
	     <managed-bean-name>divisionForm</managed-bean-name>
	     <managed-bean-class>com.jruffin.web.DivisionForm</managed-bean-class>
	     <managed-bean-scope>request</managed-bean-scope>	
              ...
             	<managed-property>
			<property-name>parent</property-name>
			<value>#{baseParent}</value>
		</managed-property>
	</managed-bean>

But in divisionForm.java the injected parent attributes are null.  How do I
populate #{baseParent} with t:saveState parent object/values?

Thanks in advance!
--
View this message in context: http://www.nabble.com/t%3AsaveState-how-to--t1521818.html#a4132708
Sent from the MyFaces - Users forum at Nabble.com.


Re: t:saveState how-to?

Posted by Mike Kienenberger <mk...@gmail.com>.
On 4/28/06, John Ruffin <jr...@achfood.com> wrote:
> Thanks JuanCarlos.  I've successfully savedState on a bean from 5 pages ago
> using a <t:saveState value="#<useTheSameBeanNameOnEachPage>".  I'm able to
> display the bean attributes on the jsp down the line.  Thank you.
>
> Here is what will put me over the top: in the "backing bean" of page5 how do
> I access the savedState bean?  Should I make a managed property in the page5
> backing bean - if so how do I inject it with the savedState bean?  Sorry,
> I'm not seeing the solution.

Ok.  I see what you're trying to do now.   I don't think you can
inject a persisted request bean using managed beans

You're probably going to need to explicitly reference the bean.

See the lookup section in

http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother

Re: t:saveState how-to?

Posted by John Ruffin <jr...@achfood.com>.
Thanks JuanCarlos.  I've successfully savedState on a bean from 5 pages ago
using a <t:saveState value="#<useTheSameBeanNameOnEachPage>".  I'm able to
display the bean attributes on the jsp down the line.  Thank you.

Here is what will put me over the top: in the "backing bean" of page5 how do
I access the savedState bean?  Should I make a managed property in the page5
backing bean - if so how do I inject it with the savedState bean?  Sorry,
I'm not seeing the solution.

(scenario stated another way)
<t:saveState value="#{mybean}" in page1
<t:saveState value="#{mybean}" in page2
...
<t:saveState value="#{mybean}" in page5

Now, inside the action/java for the form on page5 - how do I access the
"mybean" data?  I want to save all the domain objects the beans represent at
one time - not a form at a time.
--
View this message in context: http://www.nabble.com/t%3AsaveState-how-to--t1521818.html#a4150715
Sent from the MyFaces - Users forum at Nabble.com.


Re: t:saveState how-to?

Posted by "Juan C. Galeano H." <jg...@unionsoluciones.com.co>.
Hi John!

I think you will get the same behavior if you get rid the ids, I mean, 
what is important in saveState is the value attribute.  The way I use 
saveState, for instance to preserve myBean state, from page1.jsp to 
page2.jsp is as follows:

<t:saveState value="#{myBean}"/> in page1.jsp

and

<t:saveState value="#{myBean}"/> in page2.jsp

where myBean is a managed bean and there's a request from page1.jsp to 
page2.jsp

I hope it helps.

JuanCarlos

>  
>

Re: t:saveState how-to?

Posted by John Ruffin <jr...@achfood.com>.
Sorry folks - just thought I'd ping the list again.  This is a bit pressing
for me.  Any feedback is appreicated.
--
View this message in context: http://www.nabble.com/t%3AsaveState-how-to--t1521818.html#a4142396
Sent from the MyFaces - Users forum at Nabble.com.


Re: t:saveState how-to?

Posted by John Ruffin <jr...@achfood.com>.
I edited the original post in Nabble, but it mentioned the changes would be
pushed to the list.  Hence the reply.  Fun stuff at crazy hours!
--
View this message in context: http://www.nabble.com/t%3AsaveState-how-to--t1521818.html#a4136167
Sent from the MyFaces - Users forum at Nabble.com.


Re: t:saveState how-to?

Posted by John Ruffin <jr...@achfood.com>.
Thanks Mike.  I think Serialization is implemented correctly.  I had some
logging statements in my form beans and t:saveState wouldn't work "inside"
<f:view> until I removed them.  All form beans implement Serialization.

>From form1.jsp with a t:saveState to form2.jsp with a t:saveState(same id) -
I can outputText from form1 on form2.  Form1 being parentForm.jsp, form2
being divisionForm.jsp.

Where I'm fuzzy is actually accessing the data from parentForm (form1) in
the backing bean of divisionForm.java (form2) - not in the jsp.  The way I
implemented the injection (see original post) returns null for all the
attributes of the bean from savedState - null in the backing bean not the
jsp.
--
View this message in context: http://www.nabble.com/t%3AsaveState-how-to--t1521818.html#a4147166
Sent from the MyFaces - Users forum at Nabble.com.


Re: t:saveState how-to?

Posted by Mike Kienenberger <mk...@gmail.com>.
On 4/27/06, John Ruffin <jr...@achfood.com> wrote:
> I want users to flow through say 2 screens then I want to save their
> submitted data.  I use t:saveState to keep the data around.
>
> I added: <t:saveState id="saveHierachy" value="#{parentForm}"/> to the first
> form and <t:saveState id="saveHierachy" value="#{divisionForm}"/> in the
> second form.  Both beans implement Serializable.  <t:saveState> is outside
> <f:view>. javax.faces.STATE_SAVING_METHOD is set to client.
>
> This works ok if I only want to display data on screen. (i.e. I can display
> data submitted in parentForm.jsp on divisionForm.jsp.  But I want to save
> when divisionForm is submitted.
>
> So, I created a managed-bean of type Parent (a domain class) - called
> baseParent like this:
>
>         <managed-bean>
>                 <managed-bean-name>baseParent</managed-bean-name>
>                 <managed-bean-class>com.jruffin.model.Parent</managed-bean-class>
>                 <managed-bean-scope>request</managed-bean-scope>
>         </managed-bean>
>
> This gets injected into divisionForm like this:
>         <managed-bean>
>              <managed-bean-name>divisionForm</managed-bean-name>
>              <managed-bean-class>com.jruffin.web.DivisionForm</managed-bean-class>
>              <managed-bean-scope>request</managed-bean-scope>
>               ...
>                 <managed-property>
>                         <property-name>parent</property-name>
>                         <value>#{baseParent}</value>
>                 </managed-property>
>         </managed-bean>
>
> But in divisionForm.java the injected parent attributes are null.  How do I
> populate #{baseParent} with t:saveState parent object/values?

Hey John,

I'd like to answer your question, but I don't quite undersatnd what
you're asking for.

t:saveState should preserve all properties of a bean, including
references to another bean, provided you've implemented Serialization
(or Stateholder) correctly.