You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-user@incubator.apache.org by David Brunette <Da...@chordiant.com> on 2007/01/24 21:12:50 UTC

Maintaining selected tab

 

     Hi.

 

     I have two simple pages, both of which have a simple
<tr:panelTabbed /> component showing the exactly same tabs and content.
On the first page, I select a different tab and then click a button that
will navigate me to the second page.  When the second page loads, I
would like to have the selected tab be the same as the one that was
selected when I submitted from the first page.

 

     I tried to do this by binding the <tr:panelTabbed /> components on
each page to the same property in my session-scoped bean, but when the
second page loads, I am always defaulted to the first tab again.  Does
anybody know how I can keep track of which tab is selected for my
panelTabbed component across different pages?  Thanks...

 

Dave

 

<tr:panelTabbed binding="#{keepTabStateBean.tabs}" position="above">

      <tr:showDetailItem text="First" immediate="true">

            <tr:outputText value="First Content" />

      </tr:showDetailItem>

      <tr:showDetailItem text="Second" immediate="true">

            <tr:outputText value="Second Content" />

      </tr:showDetailItem>

      <tr:showDetailItem text="Third" immediate="true">

            <tr:outputText value="Third Content" />

      </tr:showDetailItem>

</tr:panelTabbed>

 

public class KeepTabStateBean {

      

      private CorePanelTabbed tabs;

 

      public final CorePanelTabbed getTabs() {

            return tabs;

      }

 

      public final void setTabs(CorePanelTabbed tabs) {

            this.tabs = tabs;

      }

 

}

The information transmitted herewith is sensitive      information of Chordiant Software or its customers and is intended only for use to the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon, this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.

RE: Maintaining selected tab

Posted by David Brunette <Da...@chordiant.com>.
     Hey Adam... thanks for the reply.

     It turns out that this context-param was already set in my app...
but it still may be the key to what my problem is.  I had never heard
about the ChangeManager before, but reading as much as I can find about
it, it seems like this is used to automatically apply some state during
subsequent creation of a particular view.  But that's exactly what I
DON'T want to happen.  When going from View_A -> View_B, I'd like the
state of the tab component (i.e. which tab is selected) to be the same
on View_B as it was on View_A.  My new understanding of the
ChangeManager is that it only helps with keeping the state of a
component when going back to View_A... and the ChangeManager will
maintain a completely separate state for the component on View_B all on
its own.  So would it be a mistake to try to use the ChangeManage if I
want to share the component state across different views?

     I have gotten this to work now by turning the ChangeManager OFF and
implementing a DisclosureListener on each of my showDetailItem
components to maintain the ID of the selected tab (for anybody
interested, the code is pasted below).  But I would like to know if this
is the best solution, or if there is a way to work with the
ChangeManager to maintain a component's state across different views.

     Thanks...

Dave

panelTabbed component:

<tr:panelTabbed position="above">

  <tr:showDetailItem id="theFirstTab"
     disclosed="#{keepTabStateBean.disclosedSectionId == 'theFirstTab'}"
     disclosureListener="#{keepTabStateBean.updateStickyTab}"
     text="First" immediate="true">
      <tr:outputText value="First Content" />
  </tr:showDetailItem>

  <tr:showDetailItem id="theSecondTab"
    disclosed="#{keepTabStateBean.disclosedSectionId == 'theSecondTab'}"
    disclosureListener="#{keepTabStateBean.updateStickyTab}"
    text="Second" immediate="true">
      <tr:outputText value="Second Content" />
  </tr:showDetailItem>

  <tr:showDetailItem id="theThirdTab"
     disclosed="#{keepTabStateBean.disclosedSectionId == 'theThirdTab'}"
     disclosureListener="#{keepTabStateBean.updateStickyTab}"
     text="Third" immediate="true">
       <tr:outputText value="Third Content" />
  </tr:showDetailItem>

</tr:panelTabbed>

KeepTabStateBean.java:

public class KeepTabStateBean {
	
	private String disclosedSectionId;
	
	public final String getDisclosedSectionId() {
		return disclosedSectionId;
	}

	public final void setDisclosedSectionId(String
disclosedSectionId) {
		this.disclosedSectionId = disclosedSectionId;
	}

	public void updateStickyTab( DisclosureEvent event ) {
		if( ( (CoreShowDetailItem)event.getComponent()
).isDisclosed() )
			setDisclosedSectionId( (
(CoreShowDetailItem)event.getComponent() ).getId() );
		
	}

}

-----Original Message-----
From: Adam Winer [mailto:awiner@gmail.com] 
Sent: Friday, January 26, 2007 9:38 PM
To: adffaces-user@incubator.apache.org
Subject: Re: Maintaining selected tab

You might try enabling the "change manager" in web.xml:

  <context-param>
 
<param-name>org.apache.myfaces.trinidad.CHANGE_PERSISTENCE</param-name>
    <param-value>session</param-value>
  </context-param>

... which will do some automatic persistence of UI changes for you.

-- Adam


On 1/25/07, David Brunette <Da...@chordiant.com> wrote:
>
>      A little more info on this...
>
>      When I select a tab and navigate to the next page, the
panelTabbed
> is defaulted back to showing the first tab.  But if I navigate back to
> the first page again, then the panelTabbed is showing the tab that I
> selected before.  It seems as though the state is being kept, but only
> page-by-page instead of for ALL pages that include that component and
> bind it to the same CorePabelTabbed.
>
>      Any ideas of what I'm missing here??  Thanks...
>
> Dave
>
> -----Original Message-----
> From: David Brunette [mailto:David.Brunette@chordiant.com]
> Sent: Wednesday, January 24, 2007 4:13 PM
> To: adffaces-user@incubator.apache.org
> Subject: Maintaining selected tab
>
>
>
>      Hi.
>
>
>
>      I have two simple pages, both of which have a simple
> <tr:panelTabbed /> component showing the exactly same tabs and
content.
> On the first page, I select a different tab and then click a button
that
> will navigate me to the second page.  When the second page loads, I
> would like to have the selected tab be the same as the one that was
> selected when I submitted from the first page.
>
>
>
>      I tried to do this by binding the <tr:panelTabbed /> components
on
> each page to the same property in my session-scoped bean, but when the
> second page loads, I am always defaulted to the first tab again.  Does
> anybody know how I can keep track of which tab is selected for my
> panelTabbed component across different pages?  Thanks...
>
>
>
> Dave
>
>
>
> <tr:panelTabbed binding="#{keepTabStateBean.tabs}" position="above">
>
>       <tr:showDetailItem text="First" immediate="true">
>
>             <tr:outputText value="First Content" />
>
>       </tr:showDetailItem>
>
>       <tr:showDetailItem text="Second" immediate="true">
>
>             <tr:outputText value="Second Content" />
>
>       </tr:showDetailItem>
>
>       <tr:showDetailItem text="Third" immediate="true">
>
>             <tr:outputText value="Third Content" />
>
>       </tr:showDetailItem>
>
> </tr:panelTabbed>
>
>
>
> public class KeepTabStateBean {
>
>
>
>       private CorePanelTabbed tabs;
>
>
>
>       public final CorePanelTabbed getTabs() {
>
>             return tabs;
>
>       }
>
>
>
>       public final void setTabs(CorePanelTabbed tabs) {
>
>             this.tabs = tabs;
>
>       }
>
>
>
> }
>
> The information transmitted herewith is sensitive      information of
> Chordiant Software or its customers and is intended only for use to
the
> individual or entity to which it is addressed. If the reader of this
> message is not the intended recipient, you are hereby notified that
any
> review, retransmission, dissemination, distribution, copying or other
> use of, or taking of any action in reliance upon, this information is
> strictly prohibited. If you have received this communication in error,
> please contact the sender and delete the material from your computer.
> The information transmitted herewith is sensitive      information of
Chordiant Software or its customers and is intended only for use to the
individual or entity to which it is addressed. If the reader of this
message is not the intended recipient, you are hereby notified that any
review, retransmission, dissemination, distribution, copying or other
use of, or taking of any action in reliance upon, this information is
strictly prohibited. If you have received this communication in error,
please contact the sender and delete the material from your computer.
>
The information transmitted herewith is sensitive      information of Chordiant Software or its customers and is intended only for use to the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon, this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.

Re: Maintaining selected tab

Posted by Adam Winer <aw...@gmail.com>.
You might try enabling the "change manager" in web.xml:

  <context-param>
    <param-name>org.apache.myfaces.trinidad.CHANGE_PERSISTENCE</param-name>
    <param-value>session</param-value>
  </context-param>

... which will do some automatic persistence of UI changes for you.

-- Adam


On 1/25/07, David Brunette <Da...@chordiant.com> wrote:
>
>      A little more info on this...
>
>      When I select a tab and navigate to the next page, the panelTabbed
> is defaulted back to showing the first tab.  But if I navigate back to
> the first page again, then the panelTabbed is showing the tab that I
> selected before.  It seems as though the state is being kept, but only
> page-by-page instead of for ALL pages that include that component and
> bind it to the same CorePabelTabbed.
>
>      Any ideas of what I'm missing here??  Thanks...
>
> Dave
>
> -----Original Message-----
> From: David Brunette [mailto:David.Brunette@chordiant.com]
> Sent: Wednesday, January 24, 2007 4:13 PM
> To: adffaces-user@incubator.apache.org
> Subject: Maintaining selected tab
>
>
>
>      Hi.
>
>
>
>      I have two simple pages, both of which have a simple
> <tr:panelTabbed /> component showing the exactly same tabs and content.
> On the first page, I select a different tab and then click a button that
> will navigate me to the second page.  When the second page loads, I
> would like to have the selected tab be the same as the one that was
> selected when I submitted from the first page.
>
>
>
>      I tried to do this by binding the <tr:panelTabbed /> components on
> each page to the same property in my session-scoped bean, but when the
> second page loads, I am always defaulted to the first tab again.  Does
> anybody know how I can keep track of which tab is selected for my
> panelTabbed component across different pages?  Thanks...
>
>
>
> Dave
>
>
>
> <tr:panelTabbed binding="#{keepTabStateBean.tabs}" position="above">
>
>       <tr:showDetailItem text="First" immediate="true">
>
>             <tr:outputText value="First Content" />
>
>       </tr:showDetailItem>
>
>       <tr:showDetailItem text="Second" immediate="true">
>
>             <tr:outputText value="Second Content" />
>
>       </tr:showDetailItem>
>
>       <tr:showDetailItem text="Third" immediate="true">
>
>             <tr:outputText value="Third Content" />
>
>       </tr:showDetailItem>
>
> </tr:panelTabbed>
>
>
>
> public class KeepTabStateBean {
>
>
>
>       private CorePanelTabbed tabs;
>
>
>
>       public final CorePanelTabbed getTabs() {
>
>             return tabs;
>
>       }
>
>
>
>       public final void setTabs(CorePanelTabbed tabs) {
>
>             this.tabs = tabs;
>
>       }
>
>
>
> }
>
> The information transmitted herewith is sensitive      information of
> Chordiant Software or its customers and is intended only for use to the
> individual or entity to which it is addressed. If the reader of this
> message is not the intended recipient, you are hereby notified that any
> review, retransmission, dissemination, distribution, copying or other
> use of, or taking of any action in reliance upon, this information is
> strictly prohibited. If you have received this communication in error,
> please contact the sender and delete the material from your computer.
> The information transmitted herewith is sensitive      information of Chordiant Software or its customers and is intended only for use to the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon, this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.
>

RE: Maintaining selected tab

Posted by David Brunette <Da...@chordiant.com>.
     A little more info on this...

     When I select a tab and navigate to the next page, the panelTabbed
is defaulted back to showing the first tab.  But if I navigate back to
the first page again, then the panelTabbed is showing the tab that I
selected before.  It seems as though the state is being kept, but only
page-by-page instead of for ALL pages that include that component and
bind it to the same CorePabelTabbed.

     Any ideas of what I'm missing here??  Thanks...

Dave

-----Original Message-----
From: David Brunette [mailto:David.Brunette@chordiant.com] 
Sent: Wednesday, January 24, 2007 4:13 PM
To: adffaces-user@incubator.apache.org
Subject: Maintaining selected tab

 

     Hi.

 

     I have two simple pages, both of which have a simple
<tr:panelTabbed /> component showing the exactly same tabs and content.
On the first page, I select a different tab and then click a button that
will navigate me to the second page.  When the second page loads, I
would like to have the selected tab be the same as the one that was
selected when I submitted from the first page.

 

     I tried to do this by binding the <tr:panelTabbed /> components on
each page to the same property in my session-scoped bean, but when the
second page loads, I am always defaulted to the first tab again.  Does
anybody know how I can keep track of which tab is selected for my
panelTabbed component across different pages?  Thanks...

 

Dave

 

<tr:panelTabbed binding="#{keepTabStateBean.tabs}" position="above">

      <tr:showDetailItem text="First" immediate="true">

            <tr:outputText value="First Content" />

      </tr:showDetailItem>

      <tr:showDetailItem text="Second" immediate="true">

            <tr:outputText value="Second Content" />

      </tr:showDetailItem>

      <tr:showDetailItem text="Third" immediate="true">

            <tr:outputText value="Third Content" />

      </tr:showDetailItem>

</tr:panelTabbed>

 

public class KeepTabStateBean {

      

      private CorePanelTabbed tabs;

 

      public final CorePanelTabbed getTabs() {

            return tabs;

      }

 

      public final void setTabs(CorePanelTabbed tabs) {

            this.tabs = tabs;

      }

 

}

The information transmitted herewith is sensitive      information of
Chordiant Software or its customers and is intended only for use to the
individual or entity to which it is addressed. If the reader of this
message is not the intended recipient, you are hereby notified that any
review, retransmission, dissemination, distribution, copying or other
use of, or taking of any action in reliance upon, this information is
strictly prohibited. If you have received this communication in error,
please contact the sender and delete the material from your computer.
The information transmitted herewith is sensitive      information of Chordiant Software or its customers and is intended only for use to the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon, this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.