org.barracudamvc.core.comp
Class BSelect

java.lang.Object
  extended byorg.barracudamvc.core.comp.AbstractBComponent
      extended byorg.barracudamvc.core.comp.BComponent
          extended byorg.barracudamvc.core.comp.BList
              extended byorg.barracudamvc.core.comp.BSelect
All Implemented Interfaces:
Attrs, BCompoundComponent, 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  BAction baction
           
protected  boolean disableBackButton
           
protected  List listeners
           
protected static org.apache.log4j.Logger logger
           
protected  org.barracudamvc.core.comp.BSelect.LocalModelListener scallback
           
protected  ListSelectionModel selectionModel
           
protected  Integer viewSize
           
 
Fields inherited from class org.barracudamvc.core.comp.BList
model
 
Fields inherited from class org.barracudamvc.core.comp.BComponent
DEFAULT_ENCODING, enabled, enc, name, rs, VISIBILITY_MARKER, visible
 
Fields inherited from class org.barracudamvc.core.comp.AbstractBComponent
attrs, children, dvc, isStepChild, parent, 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
 BSelect addEventListener(ListenerFactory lf)
          Add an event listener to this component.
 BSelect addEventListener(ListenerFactory lf, boolean idisableBackButton)
          Add an event listener to this component.
 void destroyCycle()
          Destroy cycle.
 BAction getAction()
          Returns the action associated with this component (if any)
 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
 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
 BSelect removeEventListener(ListenerFactory lf)
          Remove an event listener from this component
 BSelect setAction(BAction ibaction)
          Specify an action for this component (rather than adding an even listener)
 BSelect setSelectedIndex(int i)
          Convenience method to set the selected index.
 BSelect setSelectionModel(ListSelectionModel imodel)
          Set the selection model that backs the list.
 BSelect setViewSize(Integer iviewSize)
          Set the view size of the component (heighth in rows).
 
Methods inherited from class org.barracudamvc.core.comp.BList
getModel, setListData, setListData, setModel
 
Methods inherited from class org.barracudamvc.core.comp.BComponent
addView, decodeStr, encodeStr, getEncoding, getFirstView, getName, getRenderStrategy, getViews, isEnabled, isVisible, postRender, removeAllViews, removeView, render, render, renderView, renderView, setEnabled, setEnabled, setEncoding, setName, setRenderStrategy, setView, setVisible, setVisible, supports
 
Methods inherited from class org.barracudamvc.core.comp.AbstractBComponent
addChild, addStepChild, addStepChild, addTempView, clearState, findComponentMap, findRendererFactory, getAttr, getAttrMap, getChild, getChildren, getDefaultViewContext, getParent, getRenderer, getRenderer, getRootComponent, getState, getStateKeys, getStateStore, hasChildren, hasViews, initCycle, installRendererFactory, invalidate, isStepChild, printStackTrace, printStackTrace, printStackTrace, putState, removeAll, removeAllStepChildren, removeChild, removeChild, removeState, setAttr, setDefaultViewContext, setParent, 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 final org.apache.log4j.Logger logger

selectionModel

protected ListSelectionModel selectionModel

scallback

protected org.barracudamvc.core.comp.BSelect.LocalModelListener scallback

listeners

protected List listeners

viewSize

protected Integer viewSize

disableBackButton

protected boolean disableBackButton

baction

protected BAction baction
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

Parameters:
imodel - the specific model to back this component
Method Detail

setSelectionModel

public BSelect 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.

Parameters:
imodel - the model that backs the list

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 BSelect 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 BSelect setViewSize(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.

Parameters:
iviewSize - an integer value representing the size.

getViewSize

public 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

setAction

public BSelect setAction(BAction ibaction)
Specify an action for this component (rather than adding an even listener)

Parameters:
ibaction - the action to be fired when the BSelect is activated on the client

getAction

public BAction getAction()
Returns the action associated with this component (if any)

Returns:
the action associated with this component (if any)

addEventListener

public BSelect addEventListener(ListenerFactory lf,
                                boolean idisableBackButton)
Add an event listener to this component.

Parameters:
lf - the event listener to be added
idisableBackButton - true if the back button should be disabled when the action occurs

addEventListener

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

Parameters:
lf - the event listener to be added

removeEventListener

public BSelect 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 © 2004 BarracudaMVC.org All Rights Reserved.