com.esri.adf.web.faces.component
Class TocControl

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UICommand
              extended by com.esri.adf.web.faces.component.TocControl
All Implemented Interfaces:
EventListener, javax.faces.component.ActionSource, javax.faces.component.ActionSource2, javax.faces.component.StateHolder, javax.faces.event.ActionListener, javax.faces.event.FacesListener

public class TocControl
extends javax.faces.component.UICommand
implements javax.faces.event.ActionListener

The TOC control—or table of contents control—displays the contents of a map and allows an end user to turn layers on and off. The TOC control functions in the same manner as the table of contents in ArcMap: it presents a hierarchical list of data frames, layers, and symbols displayed on the map.

The TocControl works with WebToc object. The TocRenderer class renders the control to the appropriate markup, and the TocTag class exposes the control as a JSP custom tag named toc.

The TOC is made up of a collection of TocNode objects. A TocNode stores content, maintains hierarchical relationships, and responds to an event that occurs at that node. To store content, a TocNode requires a TocNodeContent object to encapsulate the content at that node. A TocNode handles its own expand or collapse event and delegates the check box event—for layer visibility—and the node operation—when node content is clicked—to the TocNodeContent’s event handling methods:

  public void handleCheckedEvent(TocEvent args)
  public void handleNodeEvent(TocEvent args)

The TocRenderer controls how the TocControl is displayed on the page and manages the events for the table of contents. The TocRenderer decodes the following request parameters from the FacesContext:
  • tocId + _nodeKey — The key of the node responsible for the operation
  • tocId + _nodeOperation — The operation to be performed, which is either click or expandCollapse


Field Summary
static String COMPONENT_FAMILY
          The standard component family for this component.
static String COMPONENT_TYPE
          The standard component type for this component.
static String DEFAULT_XSL_FILE_NAME
          The name of the XSL file used to render this control by default.
 
Fields inherited from class javax.faces.component.UIComponent
bindings
 
Constructor Summary
TocControl()
          Initializes the TocControl.
 
Method Summary
 String getCollapsedImage()
          Returns the collapsed image URL.
 String getExpandedImage()
          Returns the expanded image URL.
 String getFamily()
          Returns the family of this control.
 int getIndentWidth()
          Returns the indentation level of the TOC nodes.
 String getMapId()
          Returns the map control id associated with the control.
protected  javax.faces.render.Renderer getRenderer(javax.faces.context.FacesContext context)
          Returns a design-time renderer if the component is used in an IDE.
 String getResourceImage()
          Returns the resource image URL.
 String getStyle()
          Returns the style attributes of toolbar control.
 String getStyleClass()
          Returns the file name where the CSS style attributes are defined.
 String getTextStyle()
          Returns the TOC text CSS style.
 String getTextStyleClass()
          Returns the TOC text CSS class name.
 TocModel getTocModel()
          Returns the TocModel object associated with this control.
 URL getXslUrl()
          Returns the URL of the XSL file used to render the control.
 boolean isAutoPostBack()
          Returns an indicator of whether to post back a TOC event.
 boolean isClientPostBack()
          Indicates whether the control supports client side post back.
 boolean isInit()
          Returns an indicator whether this control is initialized.
 boolean isShowExpanded()
          Returns an indicator of whether to show collapsed/expanded images on the TOC.
 void processAction(javax.faces.event.ActionEvent event)
          Processes an action fired by this control.
 TocEvent queueTocEvent(javax.faces.context.FacesContext facesContext, String nodeKey, int nodeOperation, String contextMenuItemValue, Map<String,Boolean> checkedNodeKeys)
          Set the event arguments passed by the client and queues the action event.
 void restoreState(javax.faces.context.FacesContext facesContext, Object state)
          Restores the state of the control.
 Object saveState(javax.faces.context.FacesContext facesContext)
          Saves the state of this control.
 void setAutoPostBack(boolean autoPostBack)
          Sets whether to automatically post back on every check or uncheck event.
 void setClientPostBack(boolean clientPostBack)
          Sets whether the control supports client side post back.
 void setCollapsedImage(String collapsedImage)
          Sets the collapsed image URL.
 void setExpandedImage(String expandedImage)
          Sets the expanded image URL.
 void setIndentWidth(int indent)
          Sets the indentation level of the TOC nodes.
 void setInit(boolean init)
          Sets an indicator whether to initialize the control.
 void setMapId(String mapId)
          Sets the map control id associated with the control.
 void setResourceImage(String resourceImage)
          Sets the resource image URL.
 void setShowExpanded(boolean showExpanded)
          Sets the visibility of the collapsed/expanded images on the TOC.
 void setStyle(String style)
          Sets the default style for the toolbar control.
 void setStyleClass(String styleClass)
          Sets the CSS class name where the CSS style attributes are defined.
 void setTextStyle(String textStyle)
          Sets the TOC text CSS style.
 void setTextStyleClass(String textStyleClass)
          Sets the TOC text CSS class name.
 void setValueExpression(String name, javax.el.ValueExpression binding)
          Sets the value binding.
 void setXslUrl(URL xslUrl)
          Sets the URL of the XSL file used to render the control.
 
Methods inherited from class javax.faces.component.UICommand
addActionListener, broadcast, getAction, getActionExpression, getActionListener, getActionListeners, getValue, isImmediate, queueEvent, removeActionListener, setAction, setActionExpression, setActionListener, setImmediate, setValue
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId, getValueExpression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_FAMILY

public static final String COMPONENT_FAMILY
The standard component family for this component.

See Also:
Constant Field Values

COMPONENT_TYPE

public static final String COMPONENT_TYPE
The standard component type for this component.

See Also:
Constant Field Values

DEFAULT_XSL_FILE_NAME

public static final String DEFAULT_XSL_FILE_NAME
The name of the XSL file used to render this control by default.

See Also:
Constant Field Values
Constructor Detail

TocControl

public TocControl()
Initializes the TocControl. The renderer type is set and the control is registered as an ActionListener.

Method Detail

getFamily

public String getFamily()
Returns the family of this control.

Overrides:
getFamily in class javax.faces.component.UICommand
Returns:
String- the COMPONENT_FAMILY

getRenderer

protected javax.faces.render.Renderer getRenderer(javax.faces.context.FacesContext context)
Returns a design-time renderer if the component is used in an IDE.

Overrides:
getRenderer in class javax.faces.component.UIComponentBase
Parameters:
context - the FacesContext
Returns:
Renderer- the renderer object

processAction

public void processAction(javax.faces.event.ActionEvent event)
                   throws javax.faces.event.AbortProcessingException
Processes an action fired by this control. The TOC control delegates event handling to the TocNode's event handling methods. It then iterates through all the checked nodes and calls the associated handleCheckedEvent method.

Specified by:
processAction in interface javax.faces.event.ActionListener
Parameters:
event - the ActionEvent
Throws:
javax.faces.event.AbortProcessingException - if the TOC node event fails

queueTocEvent

public TocEvent queueTocEvent(javax.faces.context.FacesContext facesContext,
                              String nodeKey,
                              int nodeOperation,
                              String contextMenuItemValue,
                              Map<String,Boolean> checkedNodeKeys)
Set the event arguments passed by the client and queues the action event. A new TocEvent is created by passing in the checked node and the boolean value indicating if the node is checked.

Parameters:
facesContext - the FacesContext
nodeKey - the node key
nodeOperation - - the operation to perform on the node (0 indicates expand/collapse, 1 indicates check/uncheck, and an integer other than -1, 0, or 1 indicates a custom operation)
contextMenuItemValue - - the value of the context menu item to be processed
checkedNodeKeys - - collection of TocEvent.CheckedTocNodes

getTocModel

public TocModel getTocModel()
Returns the TocModel object associated with this control.

Returns:
TocModel- the TocModel

isInit

public boolean isInit()
Returns an indicator whether this control is initialized.

Returns:
boolean- if true, the control is initialized

setInit

public void setInit(boolean init)
Sets an indicator whether to initialize the control.

Parameters:
init - if true, initialize the control

setValueExpression

public void setValueExpression(String name,
                               javax.el.ValueExpression binding)
Sets the value binding. For the "value" attribute it checks if it is an instanceof TocModel or not. If not, it throws an ADFException. For all other cases, it simply calls super.setValueBinding()

Overrides:
setValueExpression in class javax.faces.component.UIComponent
Parameters:
name - the name of the attribute or property for which to set a ValueBinding
binding - the ValueBinding to set. If null, remove any currently set ValueBinding.

getMapId

public String getMapId()
Returns the map control id associated with the control.

Returns:
String - the map control id

setMapId

public void setMapId(String mapId)
Sets the map control id associated with the control.

Parameters:
mapId - the map control id.

getXslUrl

public URL getXslUrl()
Returns the URL of the XSL file used to render the control.

Returns:
URL- the URL object

setXslUrl

public void setXslUrl(URL xslUrl)
Sets the URL of the XSL file used to render the control.

Parameters:
xslUrl - the URL of the XSL file

getStyle

public String getStyle()
Returns the style attributes of toolbar control.

Returns:
String- the style attributes

setStyle

public void setStyle(String style)
Sets the default style for the toolbar control.

Parameters:
style - the default style for the toolbar control

getStyleClass

public String getStyleClass()
Returns the file name where the CSS style attributes are defined.

Returns:
String- the CSS class

setStyleClass

public void setStyleClass(String styleClass)
Sets the CSS class name where the CSS style attributes are defined.

Parameters:
styleClass - the CSS class

isClientPostBack

public boolean isClientPostBack()
Indicates whether the control supports client side post back.

Returns:
boolean- if true, the client side post back is supported

setClientPostBack

public void setClientPostBack(boolean clientPostBack)
Sets whether the control supports client side post back.

Parameters:
clientPostBack - if true, the client side post back is supported

isAutoPostBack

public boolean isAutoPostBack()
Returns an indicator of whether to post back a TOC event.

Returns:
boolean- if true, every TOC event is sent to the server

setAutoPostBack

public void setAutoPostBack(boolean autoPostBack)
Sets whether to automatically post back on every check or uncheck event.

Parameters:
autoPostBack - if true, a TOC request is sent to the server after each event

getTextStyle

public String getTextStyle()
Returns the TOC text CSS style.

Returns:
String- the TOC text CSS style

setTextStyle

public void setTextStyle(String textStyle)
Sets the TOC text CSS style.

Parameters:
textStyle - the TOC text CSS style

getTextStyleClass

public String getTextStyleClass()
Returns the TOC text CSS class name.

Returns:
String- the TOC text CSS class name

setTextStyleClass

public void setTextStyleClass(String textStyleClass)
Sets the TOC text CSS class name.

Parameters:
textStyleClass - the TOC text CSS class name

getIndentWidth

public int getIndentWidth()
Returns the indentation level of the TOC nodes.

Returns:
int- the indentation level

setIndentWidth

public void setIndentWidth(int indent)
Sets the indentation level of the TOC nodes.

Parameters:
indent - the number of pixels to indent nodes

getExpandedImage

public String getExpandedImage()
Returns the expanded image URL.

Returns:
String- a URL string to the image

setExpandedImage

public void setExpandedImage(String expandedImage)
Sets the expanded image URL.

Parameters:
expandedImage - a URL string to the image

getCollapsedImage

public String getCollapsedImage()
Returns the collapsed image URL.

Returns:
String - a URL string to the image

setCollapsedImage

public void setCollapsedImage(String collapsedImage)
Sets the collapsed image URL.

Parameters:
collapsedImage - a URL string to the image

getResourceImage

public String getResourceImage()
Returns the resource image URL.

Returns:
String- the resource image URL

setResourceImage

public void setResourceImage(String resourceImage)
Sets the resource image URL.

Parameters:
resourceImage - a URL string to the image

setShowExpanded

public void setShowExpanded(boolean showExpanded)
Sets the visibility of the collapsed/expanded images on the TOC.

Parameters:
showExpanded - set to true to show the collapsed/expanded images

isShowExpanded

public boolean isShowExpanded()
Returns an indicator of whether to show collapsed/expanded images on the TOC.

Returns:
boolean- if set to true, collapsed/expanded images will show

saveState

public Object saveState(javax.faces.context.FacesContext facesContext)
Saves the state of this control.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.component.UICommand
Parameters:
facesContext - the associated FacesContext
Returns:
Object- the object to be saved

restoreState

public void restoreState(javax.faces.context.FacesContext facesContext,
                         Object state)
Restores the state of the control.

Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.component.UICommand
Parameters:
facesContext - the associated FacesContext
state - the object to restore the state of the control from