org.enhydra.barracuda.core.comp
Class BSelect

java.lang.Object
  |
  +--org.enhydra.barracuda.core.comp.AbstractBComponent
        |
        +--org.enhydra.barracuda.core.comp.BComponent
              |
              +--org.enhydra.barracuda.core.comp.BList
                    |
                    +--org.enhydra.barracuda.core.comp.BSelect
All Implemented Interfaces:
BContainer, StateMap

public class BSelect
extends BList

A BSelect element is used to render a list of items, and to indicate which element(s) are selected. It is typically used to manipulate <select> elements.

In most cases you will not actually need to bind the component to a view in order to use it--if you return it from a model, this will be done for you automatically. If however, you intend to use the component standalone (ie. manually attaching it to a specific node in the DOM) or inline (ie. in a toString()), then you MUST BIND IT TO A VIEW before rendering, or an error will be generated.


Field Summary
protected  boolean disableBackButton
           
protected  java.util.List listeners
           
protected static org.apache.log4j.Logger logger
           
protected  org.enhydra.barracuda.core.comp.BSelect.LocalModelListener scallback
           
protected  ListSelectionModel selectionModel
           
protected  java.lang.Integer viewSize
           
 
Fields inherited from class org.enhydra.barracuda.core.comp.BList
model
 
Fields inherited from class org.enhydra.barracuda.core.comp.BComponent
attrs, CACHING_MARKER, enabled, name, rs, VISIBILITY_MARKER, visible
 
Fields inherited from class org.enhydra.barracuda.core.comp.AbstractBComponent
children, dvc, isStepChild, parent, preventCaching, statemap, stepChildren, tempViews, validated, views
 
Constructor Summary
BSelect()
          Public noargs constructor
BSelect(ListModel imodel)
          Public constructor which creates the component and associates it with a ListModel
 
Method Summary
 void addEventListener(ListenerFactory lf)
          Add an event listener to this component.
 void destroyCycle()
          Destroy cycle.
 boolean getDisableBackButton()
          Get disable back button
 int getSelectedIndex()
          Convenience method to get the selected index (if the component allows multiple selections, this will return the index of the first selected item).
 int[] getSelectedIndexes()
          Convenience method to return an int array containing all selected indexes.
 ListSelectionModel getSelectionModel()
          Get the selection model that backs the list
 java.lang.Integer getViewSize()
          Get the size of the component.
protected  void preRender(ViewContext vc, int depth)
          Here in the pre-render phase we actually add BAction step children for any of the listeners that might have been added to this component
 void removeEventListener(ListenerFactory lf)
          Remove an event listener from this component
 void setDisableBackButton(boolean idisableBackButton)
          Set disable back button (only works if your client supports Javascript)
 void setSelectedIndex(int i)
          Convenience method to set the selected index.
 void setSelectionModel(ListSelectionModel imodel)
          Set the selection model that backs the list.
 void setViewSize(java.lang.Integer iviewSize)
          Set the view size of the component (heighth in rows).
 
Methods inherited from class org.enhydra.barracuda.core.comp.BList
getModel, setListData, setListData, setModel
 
Methods inherited from class org.enhydra.barracuda.core.comp.BComponent
addView, getAttr, getAttrMap, getFirstView, getName, getRenderStrategy, getViews, isEnabled, isVisible, postRender, removeAllViews, removeView, render, render, renderView, renderView, setAttr, setEnabled, setEnabled, setName, setRenderStrategy, setView, setVisible, setVisible, supports
 
Methods inherited from class org.enhydra.barracuda.core.comp.AbstractBComponent
addChild, addStepChild, addStepChild, addTempView, findComponentMap, findRendererFactory, getChild, getChildren, getDefaultViewContext, getParent, getPreventCaching, getRenderer, getRenderer, getRootComponent, getState, getStateKeys, getStateValues, hasChildren, hasViews, initCycle, installRendererFactory, invalidate, isStepChild, printStackTrace, printStackTrace, printStackTrace, putState, removeAll, removeAllStepChildren, removeChild, removeChild, removeState, setDefaultViewContext, setParent, setPreventCaching, toRef, toString, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger

selectionModel

protected ListSelectionModel selectionModel

scallback

protected org.enhydra.barracuda.core.comp.BSelect.LocalModelListener scallback

listeners

protected java.util.List listeners

viewSize

protected java.lang.Integer viewSize

disableBackButton

protected boolean disableBackButton
Constructor Detail

BSelect

public BSelect()
Public noargs constructor


BSelect

public BSelect(ListModel imodel)
Public constructor which creates the component and associates it with a ListModel

Method Detail

setSelectionModel

public void setSelectionModel(ListSelectionModel imodel)
Set the selection model that backs the list. This causes the list to register as a listener on the model, so any changes to it will be reflected in the list. If no SelectionModel is specified, a DefaultSelectionModel will be used.


getSelectionModel

public ListSelectionModel getSelectionModel()
Get the selection model that backs the list

Returns:
the selection model that backs the list

getSelectedIndex

public int getSelectedIndex()
Convenience method to get the selected index (if the component allows multiple selections, this will return the index of the first selected item). Returns a -1 if there are no selected items

Returns:
the index of the first selected item

setSelectedIndex

public void setSelectedIndex(int i)
Convenience method to set the selected index. Any other selected indexes will be cleared first. Setting this value to -1 effectively clears all selections.

Parameters:
i - the index to be selected

getSelectedIndexes

public int[] getSelectedIndexes()
Convenience method to return an int array containing all selected indexes. Returns a null if there are no selected items

Returns:
an int array for selected indexes

setViewSize

public void setViewSize(java.lang.Integer iviewSize)
Set the view size of the component (heighth in rows). If this value remains null, the height will default to whatever is specified in the underlying markup. If you set this value, then the size will be overridden in all the views associated with this component. Values less than 1 will be ignored.


getViewSize

public java.lang.Integer getViewSize()
Get the size of the component. May return a null if the size has not been manually specified. In this case, the renderer will simply not set the size attribute in the underlying markup, leaving it to default to whatever is already there.

Returns:
the view size

setDisableBackButton

public void setDisableBackButton(boolean idisableBackButton)
Set disable back button (only works if your client supports Javascript)


getDisableBackButton

public boolean getDisableBackButton()
Get disable back button

Returns:
true if we want the back button disabled

addEventListener

public void addEventListener(ListenerFactory lf)
Add an event listener to this component.

Parameters:
lf - the event listener to be added

removeEventListener

public void removeEventListener(ListenerFactory lf)
Remove an event listener from this component

Parameters:
lf - the event listener to be removed

preRender

protected void preRender(ViewContext vc,
                         int depth)
Here in the pre-render phase we actually add BAction step children for any of the listeners that might have been added to this component

Overrides:
preRender in class BComponent

destroyCycle

public void destroyCycle()
Destroy cycle. The component should use this cycle to perform any special cleanup.

Overrides:
destroyCycle in class BList


Copyright © 2001 Enhydra.org