Ok so if i store the selectedItemId field of my component in state via
it's saveState method I would think that acrossed requests to
different views it would restore it's value right?  What my concern is
is that I've missed some important method i need to implement in order
to create this custom component. The reason is this...if i run a page
with my component and click one of the navigatorItems the decode
method in my component's renderer is run and the selectedItemId field
in my component is set. If I look at the address of my component
object while debugging through the setter methods for the
selectedItemId field it will be something like (just making up an
address for example) [EMAIL PROTECTED] but when it hits the
saveState method there is a new object address or in other words a new
HtmlNavigatorPanel was created and so my selectedItemId value doesn't
get saved because it's null in the new object. I am sure the
isTransient method is returning false for the component.

Part of me thinks this behavior is correct because of the nature of my
component. Say I have two jsps

A.jsp

<f:view> 
<!--navigatorPanel_A-->
<my:navigatorPanel id="navigatorPanel_navigation" layout="horizontal"
selectedItemId="#{navigatorBean.selectedItemId}">
<my:navigatorItem id="navigatorItem_A" value="A" action="goToA" />
<my:navigatorItem id="navigatorItem_B" value="B" action="goToB" />
</my:navigatorPanel>
</f:view>

and then 

B.jsp also has the my:navigatorPanel component included in it...in
real life I am using jsp:includes to a subview page that has the
my:navigatorPanel component


<f:view> 
<!--navigatorPanel_B-->
<my:navigatorPanel id="navigatorPanel_navigation" layout="horizontal"
selectedItemId="#{navigatorBean.selectedItemId}">
<my:navigatorItem id="navigatorItem_A" value="A" action="goToA" />
<my:navigatorItem id="navigatorItem_B" value="B" action="goToB" />
</my:navigatorPanel>
</f:view>

So when I click the B navigator item from A.jsp  I'm going to a whole
different view and so a new view root would be created which would
explain why I'm seeing a new NavigatorPanel object being created with
an empty state. Now in this example I have the value of the
selectedItemId bound to an attribute in a session scoped managed bean
called navigatorBean and so my component works fine. But what I
initially thought i could do was just store the value of
selectedItemId in the state of the component and not have to bind it
to a managed bean. If i take away that value binding the
selectedItemId isn't saved from one view to the next.

             Any thoughts?
                          Galen




On 7/22/05, Enrique Medina <[EMAIL PROTECTED]> wrote:
> Hi,
>  
>  I think you should differentiate between the state of the component and the
> value binded to the component. The state is stored in session (if server)
> and as hidden fields (in client), so I don't think you will face problems
> with that.
>  
>  Maybe your question is more about the value of the components, which is
> usually binded to a backing bean that, if request scoped, is recreated in
> each new request (so the value is lost from request to request). If you need
> to preserve the value from request to request then you should bind your
> value to the session or have a look at the Dialogs from Shale (there has
> been a lot of discussion about the scope in this forum).
>  
>  Hope it helps,
>  Enrique Medina.
> 
> 2005/7/21, Galen Dunkleberger <[EMAIL PROTECTED]>:
> > Am I correct in believing a component only holds its state for the
> > life of a single view. So that if the "same" component is in two
> > differenet views and I navigate from one view to other the component
> > will not retain it's state from the previouse view without it's values 
> > or itself being bound to a session scoped managed-bean? Or is it
> > possible for a component to save it's own state acrossed multiple
> > views?
> >                                            Thanks,
> >                                                Galen
> > 
> 
>

Reply via email to