net.sf.tapestry.contrib.palette
Class Palette

java.lang.Object
  |
  +--com.primix.tapestry.AbstractComponent
        |
        +--com.primix.tapestry.BaseComponent
              |
              +--net.sf.tapestry.contrib.palette.Palette
All Implemented Interfaces:
IComponent, IFormComponent, IRender

public class Palette
extends BaseComponent
implements IFormComponent

A component used to make a number of selections from a list. The general look is a pair of <select> elements. with a pair of buttons between them. The right element is a list of values that can be selected. The buttons move values from the right column ("available") to the left column ("selected").

This all takes a bit of JavaScript to accomplish (quite a bit), which means a Body component must wrap the Palette. If JavaScript is not enabled in the client browser, then the user will be unable to make (or change) any selections.

RR
Parameter Type Read / Write Required Default Description
selected List R yes   A list of selected values. Possible selections are defined by the model; this should be a subset of the possible values. The Set must be writable; when the form is submitted, the set will be cleared and filled with the values selected by the user.

The order may be set by the user, as well, depending on the sortMode parameter.

model IPropertySelectionModel R yes   Works, as with a PropertySelection component, to define the possible values.
sort SortMode R no SortMode.NONE Controls automatic sorting of the options.
rows int R no 10 The number of rows that should be visible in the Pallete's <select> elements.
tableClass String R no tapestry-palette The CSS class for the table which surrounds the other elements of the Palette.
selectedTitleBlock Block no "Selected" If specified, allows a Block to be placed within the <th> reserved for the title above the selected items <select> (on the right). This allows for images or other components to be placed there. By default, the simple word Selected is used.
availableTitleBlock Block no "Available" As with selectedTitleBlock, but for the left column, of items which are available to be selected. The default is the word Available.
selectImage
selectDisabledImage
deselectImage
deselectDisabledImage
upImage
upDisabledImage
downImage
downDisabledImage
IAsset R no   If any of these are specified then they override the default images provided with the component. This allows the look and feel to be customized relatively easily.

The most common reason to replace the images is to deal with backgrounds. The default images are anti-aliased against a white background. If a colored or patterned background is used, the default images will have an ugly white fringe. Until all browsers have full support for PNG (which has a true alpha channel), it is necessary to customize the images to match the background.

Version:
$Id: Palette.java,v 1.9 2001/09/04 01:27:47 hship Exp $
Author:
Howard Ship

Fields inherited from class com.primix.tapestry.BaseComponent
outer, OUTER_INIT_SIZE, outerCount
 
Fields inherited from class com.primix.tapestry.AbstractComponent
id, page, specification, wrapped, wrappedCount
 
Constructor Summary
Palette()
           
 
Method Summary
 void finishLoad(IPageLoader loader, ComponentSpecification spec)
          Allows a component to finish any setup after it has been constructed.
 IRender getAvailableSelectDelegate()
          Renders the available select by closing the nested writer for the available selects.
 IBinding getAvailableTitleBlockBinding()
           
 IAsset getDeselectImage()
           
 IAsset getDownImage()
           
 IForm getForm()
          Returns the Form which contains the component.
 IBinding getModelBinding()
           
 java.lang.String getName()
          Returns the name used for the selected (right column) <select> element.
 int getRows()
           
 IBinding getRowsBinding()
           
 IBinding getSelectedBinding()
           
 IRender getSelectedSelectDelegate()
          Like getAvailableSelectDelegate(), but for the right, selected, column.
 IBinding getSelectedTitleBlockBinding()
           
 IAsset getSelectImage()
           
 SortMode getSort()
           
 IBinding getSortBinding()
           
 java.util.Map getSymbols()
           
 java.lang.String getTableClass()
           
 IBinding getTableClassBinding()
           
 IAsset getUpImage()
           
 boolean isSortUser()
           
 void render(IResponseWriter writer, IRequestCycle cycle)
          The principal rendering/rewinding method.
 void setAvailableTitleBlockBinding(IBinding value)
           
 void setModelBinding(IBinding value)
           
 void setRowsBinding(IBinding value)
           
 void setSelectedBinding(IBinding value)
           
 void setSelectedTitleBlockBinding(IBinding value)
           
 void setSortBinding(IBinding value)
           
 void setTableClassBinding(IBinding value)
           
 
Methods inherited from class com.primix.tapestry.BaseComponent
addOuter, readTemplate
 
Methods inherited from class com.primix.tapestry.AbstractComponent
addAsset, addComponent, addWrapped, cleanupAfterRender, cleanupComponent, finishLoad, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, generateAttributes, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getChangeObserver, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getPage, getSpecification, prepareForRender, renderWrapped, reset, setBinding, setContainer, setId, setPage, setSpecification, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.primix.tapestry.IComponent
addAsset, addComponent, addWrapped, getAsset, getAssets, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getPage, getSpecification, renderWrapped, setBinding, setContainer, setId, setPage, setSpecification
 

Constructor Detail

Palette

public Palette()
Method Detail

finishLoad

public void finishLoad(IPageLoader loader,
                       ComponentSpecification spec)
                throws PageLoaderException
Description copied from interface: IComponent
Allows a component to finish any setup after it has been constructed.

The exact timing is not specified, but any components contained by the receiving component will also have been constructed before this method is invoked.

As of release 1.0.6, this method is invoked before bindings are set. This should not affect anything, as bindings should only be used during renderring.

Specified by:
finishLoad in interface IComponent
Overrides:
finishLoad in class BaseComponent

setTableClassBinding

public void setTableClassBinding(IBinding value)

getTableClassBinding

public IBinding getTableClassBinding()

setSelectedTitleBlockBinding

public void setSelectedTitleBlockBinding(IBinding value)

getSelectedTitleBlockBinding

public IBinding getSelectedTitleBlockBinding()

setAvailableTitleBlockBinding

public void setAvailableTitleBlockBinding(IBinding value)

getAvailableTitleBlockBinding

public IBinding getAvailableTitleBlockBinding()

setSelectedBinding

public void setSelectedBinding(IBinding value)

getSelectedBinding

public IBinding getSelectedBinding()

setModelBinding

public void setModelBinding(IBinding value)

getModelBinding

public IBinding getModelBinding()

setRowsBinding

public void setRowsBinding(IBinding value)

getRowsBinding

public IBinding getRowsBinding()

getRows

public int getRows()

getTableClass

public java.lang.String getTableClass()

setSortBinding

public void setSortBinding(IBinding value)

getSortBinding

public IBinding getSortBinding()

getSort

public SortMode getSort()

getName

public java.lang.String getName()
Returns the name used for the selected (right column) <select> element.
Specified by:
getName in interface IFormComponent

getForm

public IForm getForm()
Description copied from interface: IFormComponent
Returns the Form which contains the component.
Specified by:
getForm in interface IFormComponent

render

public void render(IResponseWriter writer,
                   IRequestCycle cycle)
            throws RequestCycleException
Description copied from interface: IRender
The principal rendering/rewinding method. This will cause the receiving component to render its top level elements (HTML text and components).

Renderring and rewinding are the exact same process. The same code that renders must be able to restore state by going through the exact same operations (even though the output is discarded).

Specified by:
render in interface IRender
Overrides:
render in class BaseComponent

getSymbols

public java.util.Map getSymbols()

getAvailableSelectDelegate

public IRender getAvailableSelectDelegate()
Renders the available select by closing the nested writer for the available selects.

getSelectedSelectDelegate

public IRender getSelectedSelectDelegate()
Like getAvailableSelectDelegate(), but for the right, selected, column.

isSortUser

public boolean isSortUser()

getSelectImage

public IAsset getSelectImage()

getDeselectImage

public IAsset getDeselectImage()

getUpImage

public IAsset getUpImage()

getDownImage

public IAsset getDownImage()