com.raritantechnologies.searchApp.taglibrary
Class TabRenderer

java.lang.Object
  extended bycom.raritantechnologies.searchApp.taglibrary.TabRenderer
All Implemented Interfaces:
IConfigurable, ISessionDataHandler
Direct Known Subclasses:
DHTMLTabRenderer

public abstract class TabRenderer
extends java.lang.Object
implements IConfigurable, ISessionDataHandler

Abstract base class for TabRenderers. The TabRenderer classes are responsible for creating tab image(s) whether it be a row or radio buttons, select list, graphic tabs etc. The TabRenderer design separates the rendering of tab controls from the rendering of tab "bodies". Subclasses of TabRenderer can implement a DHTML client-side or completely server-side approach.

TabRenderers can be used by other types of renderers such as TabbedSearchFormRenderer, TabbedDisplayFormRenderer, TabbedResultRenderer or TabbedCustomTags (for general tabbed pages).

TabRenderer implements the ISessionDataHandler interface. It sets up a persistent parameter with the SessionDataManager to maintain the currently selected tab view. Subclasses need only be concerned with handling the rendering operations of tabs and tab bodies.

XML Configuration Template:
  <TabRenderer class="com.raritantechnologies.searchApp.taglibrary.TabRenderer" 
                  initialTab="tabID to set active initially";
                  tabSetName="[ name of tab set used in javascript ]"
                  tabSetParam="[request param name used to set tab]"
                  tabFormName="[name of form in which this tab will be used]"
                  createForm="true|false(default)"
                  needsResults="true|false(default)"
                  hideOn="[ param=value|param2=value2 pairs that will turn this off ]"
                  showOn="[ param=value|param2=value2 pairs that will turn this on ]"
                  . . . additional parameters required by subclass . . . >

    <Tab ID="tabID" display="display name" />

    <!-- Alternatively - can use IRequestFormatter to get the tab name dynamically -->
    <Tab ID="tabID" >
      <RequestFormatter class="[ class of com.raritantechnologies.quickstart.taglibrary.request.IRequestFormatter ]" >

      </RequestFormatter>
    </Tab>

    <!-- Tabs can be dynamic (dependent on request parameters) by adding a selection criterion -->
    <Tab ID="[ the Tab ID ]" display="[ the display name ]" >
       <!-- RequestComparator Tag: -->
       <RequestComparator param="[ request parameter ]" class="[ class of com.raritantechnologies.utils.comparators.IComparator ]" >
       
       </RequestComparator>
    </Tab>

  </TabRenderer>
                
 
Control flow of Tabbed renderer clients interacting with the TabRenderer class:
Developed by Raritan Technologies .

Author:
Ted Sullivan

Field Summary
protected  java.lang.String action
           
protected  java.lang.String auxTabFunction
           
protected  java.lang.String auxTabScript
           
protected  boolean createForm
           
protected  java.util.Map hideOnMap
           
protected  java.lang.String initialTab
           
protected  boolean needsResultSet
           
protected  java.lang.String renderDivs
           
protected  java.util.Map showOnMap
           
protected  java.lang.String tabFormName
           
protected  OrderedMap tabNameMap
           
protected  java.lang.String tabSetName
           
protected  java.lang.String tabSetParam
           
 
Constructor Summary
TabRenderer()
           
 
Method Summary
 void addTab(java.lang.String tabID, java.lang.String tabDisplay)
           
 void clearTabMap()
           
protected abstract  java.lang.String doRenderTabs(java.util.Iterator tabNames, java.lang.String activeTab, RaritanPageContext pageContext)
          Creates HTML for tab set.
protected  java.lang.String getActiveTab(RaritanPageContext pageContext)
           
protected  java.lang.String getDisplayName(java.lang.String tabID, RaritanPageContext pContext)
           
 java.lang.String getOnSubmitHandler(java.lang.String formName, RaritanPageContext rpc)
          returns a javascript onSubmit handler suitable for the current page context.
 java.lang.String getOnSubmitHandler(java.lang.String formName, RaritanPageContext rpc, boolean submitForm)
           
abstract  java.util.Iterator getRenderedBodies(java.util.Iterator tabNames, RaritanPageContext pageContext)
          Determine which tabs are to be rendered: Server side implementation will return single tabName based on "active Tab" defined in RaritanPageContext parameter.
Client side implementation will render all (with
tags for example) with the active tab visible and the other tabs hidden, plus appropriate javascript to toggle between the tabs.
 java.lang.String getSubmitHandlerName(java.lang.String formName)
           
 OrderedMap getTabNameMap()
           
 java.lang.String getTabSetParam()
           
 void handleSessionData(java.util.Map sessionDataMap, RaritanPageContext req)
          Updates session data parameters handled by this handler and/or updates handler parameters.
 void initialize(org.w3c.dom.Element elem)
          Initializes the object from an XML tag or element.
protected  boolean isActive(java.lang.String tabName, RaritanPageContext pageContext)
           
 void registerDataHandler(ISessionDataManager manager, java.util.Map params)
          Register this SessionDataHandler with a SessionDataManager.
abstract  java.lang.String renderBody(java.lang.String tabName, java.lang.String tabBody, RaritanPageContext pageContext)
          Renders the tab body given the tab name and an HTML fragment that will be incorporated into the tab body.
 java.lang.String renderTabForm(RaritanPageContext pageContext)
          Render the <form> tag if necessary.
 java.lang.String renderTabs(java.util.Iterator tabNames, RaritanPageContext pageContext)
          render the tab set as HTML.
 void setAuxilliaryFunction(java.lang.String auxFunctionName)
           
 void setAuxilliaryJavascript(java.lang.String javascript)
          Sets an auxillary javascript function that takes a tabID and does some client-dependent processing.
 void setCreateForm(boolean createForm)
           
 void setInitialTab(java.lang.String initialTab)
           
 void setTabFormName(java.lang.String tabFormName)
           
 void setTabSetName(java.lang.String tabSetName)
           
 void setTabSetParam(java.lang.String tabSetParam)
           
 void updateContext(RaritanPageContext pageContext)
          Updates the current tab context - determines the current "active" tab based on the parameters passed via the pageContext parameter.
 void updateContext(java.lang.String currentTabSet, RaritanPageContext pageContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

action

protected java.lang.String action

tabSetParam

protected java.lang.String tabSetParam

tabSetName

protected java.lang.String tabSetName

tabFormName

protected java.lang.String tabFormName

tabNameMap

protected OrderedMap tabNameMap

hideOnMap

protected java.util.Map hideOnMap

showOnMap

protected java.util.Map showOnMap

initialTab

protected java.lang.String initialTab

renderDivs

protected java.lang.String renderDivs

auxTabScript

protected java.lang.String auxTabScript

auxTabFunction

protected java.lang.String auxTabFunction

createForm

protected boolean createForm

needsResultSet

protected boolean needsResultSet
Constructor Detail

TabRenderer

public TabRenderer()
Method Detail

initialize

public void initialize(org.w3c.dom.Element elem)
Description copied from interface: IConfigurable
Initializes the object from an XML tag or element. This method is called by the Framework as part of the application initializtion. see ConfigurationManager, XMLConfigurationManager, XMLSearchFieldMapFactory, XMLSearchSourceFactory. Configurable objects that are owned or contained by other configurable objects will be initialized in by the parent object.

Specified by:
initialize in interface IConfigurable

clearTabMap

public void clearTabMap()

addTab

public void addTab(java.lang.String tabID,
                   java.lang.String tabDisplay)

setInitialTab

public void setInitialTab(java.lang.String initialTab)

setCreateForm

public void setCreateForm(boolean createForm)

setTabSetName

public void setTabSetName(java.lang.String tabSetName)

setTabSetParam

public void setTabSetParam(java.lang.String tabSetParam)

getTabSetParam

public java.lang.String getTabSetParam()

setTabFormName

public void setTabFormName(java.lang.String tabFormName)

updateContext

public void updateContext(RaritanPageContext pageContext)
Updates the current tab context - determines the current "active" tab based on the parameters passed via the pageContext parameter.


updateContext

public void updateContext(java.lang.String currentTabSet,
                          RaritanPageContext pageContext)

registerDataHandler

public void registerDataHandler(ISessionDataManager manager,
                                java.util.Map params)
Description copied from interface: ISessionDataHandler
Register this SessionDataHandler with a SessionDataManager.

Specified by:
registerDataHandler in interface ISessionDataHandler
Parameters:
manager - The ISessionDataManager that this handler should register with by calling manager.addSessionDataHandler( "handler name", this );
params - Initialization parameters for this handler (typically obtained from the Configuration layer.

handleSessionData

public void handleSessionData(java.util.Map sessionDataMap,
                              RaritanPageContext req)
Description copied from interface: ISessionDataHandler
Updates session data parameters handled by this handler and/or updates handler parameters.

Specified by:
handleSessionData in interface ISessionDataHandler
Parameters:
sessionDataMap - The entire param=value map cached for the current user session. The handler should update any of its params based on the current page context.
req - The current page context. Contains request parameters that the handler should use to update its and/or the SessionData's context.

getOnSubmitHandler

public java.lang.String getOnSubmitHandler(java.lang.String formName,
                                           RaritanPageContext rpc)
returns a javascript onSubmit handler suitable for the current page context. Ensures that tab state is copied to the form hidden fields prior to submission of the form. Also, ensures that any currently defined javascript persistent parameters are copied to the correct hidden fields in the form. Note that the initialization of the hidden fields is done by the addSearchFormFields, which should also be called by the client. (see TabbedSearchFormRenderer for example).


getOnSubmitHandler

public java.lang.String getOnSubmitHandler(java.lang.String formName,
                                           RaritanPageContext rpc,
                                           boolean submitForm)

getSubmitHandlerName

public java.lang.String getSubmitHandlerName(java.lang.String formName)

isActive

protected boolean isActive(java.lang.String tabName,
                           RaritanPageContext pageContext)

getActiveTab

protected java.lang.String getActiveTab(RaritanPageContext pageContext)

renderTabForm

public java.lang.String renderTabForm(RaritanPageContext pageContext)
Render the <form> tag if necessary. Users of TabRenderer must call this function so that this form tag is not nested within another form tag.


getDisplayName

protected java.lang.String getDisplayName(java.lang.String tabID,
                                          RaritanPageContext pContext)

renderTabs

public java.lang.String renderTabs(java.util.Iterator tabNames,
                                   RaritanPageContext pageContext)
render the tab set as HTML.

Parameters:
tabNames - Ordered list of java.lang.String with the display name of each tab.
Returns:
HTML fragment for the tab set.

getTabNameMap

public OrderedMap getTabNameMap()

doRenderTabs

protected abstract java.lang.String doRenderTabs(java.util.Iterator tabNames,
                                                 java.lang.String activeTab,
                                                 RaritanPageContext pageContext)
Creates HTML for tab set.

Parameters:
tabNames - Ordered list of java.lang.String with the display name of each tab.
Returns:
HTML fragment for the tab set.

getRenderedBodies

public abstract java.util.Iterator getRenderedBodies(java.util.Iterator tabNames,
                                                     RaritanPageContext pageContext)
Determine which tabs are to be rendered:


renderBody

public abstract java.lang.String renderBody(java.lang.String tabName,
                                            java.lang.String tabBody,
                                            RaritanPageContext pageContext)
Renders the tab body given the tab name and an HTML fragment that will be incorporated into the tab body.


setAuxilliaryJavascript

public void setAuxilliaryJavascript(java.lang.String javascript)
Sets an auxillary javascript function that takes a tabID and does some client-dependent processing.


setAuxilliaryFunction

public void setAuxilliaryFunction(java.lang.String auxFunctionName)