Differences between revisions 1 and 2
Revision 1 as of 2005-08-19 23:58:50
Size: 4325
Comment: initial drop
Revision 2 as of 2009-09-20 23:01:32
Size: 4325
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

TabbedPane Memory

Authors: Alexander Jesse

An tabbed pane memory component is available as module TabMemory in cvs for the jsf-comp [http://sourceforge.net/cvs/?group_id=137466 ] project.

This tabbed pane memory component allows you to enable the t:panelTabbedPane component to remember the selected tab. Actually the panelTabbedPane will always display the first tab when the tap-page is called from some other page. For most cases this behaviour will be ok, but form some cases, eg when you kick off a wizard like search from one of the tabs, it might be more natural for the user if the flow comes back to the originating tab. Also in some cases it might be desirable to jump to a specific tab. The component consists of a TabChangeListener and a managed bean. The TabChangeListener just sets the managed beans selected tab index. The managed bean supplies the selected tab index, whenever the tab-page is displayed and offers an action method which allows to display a specific tab from a commandlink.

The cvs-module contains a (almost) complete web-application with the two classes and the necessary contents from MyFaces example application to demostrate the feature. Just add the jar-files from MyFaces into the /WEB-INF/lib folder, compile and deploy to a web-container.

For assistance, send email to "ajesse -at- users.sourceforge.net" or ask on the "myfaces user mailing-list".

To enable a tabbedPane to remember, just add a session-context managed bean to your application's faces-config.xml and add a t:tabChangeListener to the t:panelTabbedPane.

tab jsp-page

 ...
  <x:panelTabbedPane bgcolor="#FFFFCC"  selectedIndex="#{exampleTabbedPane.selectedIndex}">
    <x:tabChangeListener type="net.sf.jsfcomp.tabmemory.TabMemoryListener" />
 ...

To enable the linking to specific tabs, the managed bean needs to be configured with the navigation outcome leading to the tab-page and the "translation table" with the logical tab-names (correctly it is a list who's position index corresonds to the tab-index).

faces-config

 ...
  <managed-bean>

    <description>

      tab-memory bean for the MyFaces example tabbed pane

    </description>

    <managed-bean-name>exampleTabbedPane</managed-bean-name>

    <managed-bean-class>net.sf.jsfcomp.tabmemory.TabMemoryBean</managed-bean-class>

    <managed-bean-scope>session</managed-bean-scope>

    <managed-property>

      <property-name>selectedIndex</property-name>

      <property-class>int</property-class>

      <value>0</value>

      <description>

        the state-holder attribute for the selected index

      </description>

    </managed-property>

    <managed-property>

      <property-name>tabNames</property-name>

      <property-class>java.util.List</property-class>

      <list-entries>

        <value-class>java.lang.String</value-class>

        <value>tab1</value>

        <value>tab2</value>

        <value>tab3</value>

      </list-entries>

      <description>

        the translations from the logical tab-name (not the labels shown to the users) to the tab-index

          </description>

    </managed-property>

    <managed-property>

      <property-name>navigationOutcome</property-name>

      <property-class>java.lang.String</property-class>

      <value>go_tabbedPane</value>

      <description>

        the navigation outcome used to jump to the tabbed pane

      </description>

    </managed-property>

  </managed-bean>

 ...
  <navigation-case>

    <description>

      Navigation rule for the tabbed_pane.

    </description>

    <from-outcome>go_tabbedPane</from-outcome>

    <to-view-id>/tabbedPane.jsp</to-view-id>

  </navigation-case>

 ...

"jump" jsp-page

 ...
  <h:commandLink id="goTab1" action="#{exampleTabbedPane.gotoTab}" immediate="true">
    <h:outputText value="Go to Tab 1"/>
    <f:param name="TabMemoryTabName" value="tab1"/>
  </h:commandLink>
 ...

In progress

Implementation notes

  • The component has also been tested against Sun's RI enhanced with the tomahawk-components.

change history of cvs-module

  • tab-memory-1-0 : initial drop

TabbedPaneMemory (last edited 2009-09-20 23:01:32 by localhost)