Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.tapestry.contrib.palette
Class Palette  view Palette download Palette.java

java.lang.Object
  extended byorg.apache.hivemind.impl.BaseLocatable
      extended byorg.apache.tapestry.AbstractComponent
          extended byorg.apache.tapestry.BaseComponent
              extended byorg.apache.tapestry.contrib.palette.Palette
All Implemented Interfaces:
org.apache.tapestry.IComponent, org.apache.tapestry.form.IFormComponent, org.apache.tapestry.IRender, org.apache.tapestry.ITemplateComponent, org.apache.hivemind.Locatable, org.apache.hivemind.LocationHolder

public abstract class Palette
extends org.apache.tapestry.BaseComponent
implements org.apache.tapestry.form.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 org.apache.tapestry.html.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.

Cross-browser compatibility is not perfect. In some cases, the org.apache.tapestry.contrib.form.MultiplePropertySelection component may be a better choice.

Parameter Type Direction Required Default Description
selected java.util.List in yes   A List of selected values. Possible selections are defined by the model; this should be a subset of the possible values. This may be null when the component is renderred. When the containing form is submitted, this parameter is updated with a new List of selected objects.

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

model org.apache.tapestry.form.IPropertySelectionModel in yes   Works, as with a org.apache.tapestry.form.PropertySelection component, to define the possible values.
sort SortMode in no SortMode.NONE 55 Controls automatic sorting of the options.
rows int in no 10 The number of rows that should be visible in the Pallete's <select> elements.
tableClass java.lang.String in no tapestry-palette The CSS class for the table which surrounds the other elements of the Palette.
selectedTitleBlock org.apache.tapestry.components.Block in no "Selected" If specified, allows a org.apache.tapestry.components.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 org.apache.tapestry.components.Block in 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
org.apache.tapestry.IAsset in 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.

A Palette requires some CSS entries to render correctly ... especially the middle column, which contains the two or four buttons for moving selections between the two columns. The width and alignment of this column must be set using CSS. Additionally, CSS is commonly used to give the Palette columns a fixed width, and to dress up the titles. Here is an example of some CSS you can use to format the palette component:

 TABLE.tapestry-palette TH
 {
   font-size: 9pt;
   font-weight: bold;
   color: white;
   background-color: #330066;
   text-align: center;
 }

 TD.available-cell SELECT
 {
   font-weight: normal;
   background-color: #FFFFFF;
   width: 200px;
 }
 
 TD.selected-cell SELECT
 {
   font-weight: normal;
   background-color: #FFFFFF;
   width: 200px;
 }
 
 TABLE.tapestry-palette TD.controls
 {
   text-align: center;
   vertical-align: middle;
   width: 60px;
 }
  


Field Summary
private  org.apache.tapestry.IScript _script
          A cached copy of the script used with the component.
private  java.util.Map _symbols
          A set of symbols produced by the Palette script.
private static int DEFAULT_ROWS
           
private static java.lang.String DEFAULT_TABLE_CLASS
           
private static int MAP_SIZE
           
 
Fields inherited from class org.apache.tapestry.BaseComponent
__CLOVER_4_0
 
Fields inherited from class org.apache.tapestry.AbstractComponent
__CLOVER_0_0
 
Fields inherited from class org.apache.hivemind.impl.BaseLocatable
 
Constructor Summary
Palette()
           
 
Method Summary
protected  void cleanupAfterRender(org.apache.tapestry.IRequestCycle cycle)
          Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)>AbstractComponent.render(IMarkupWriter, IRequestCycle) 55 after the component renders, to clear any parameters back to null (or 0, or false, or whatever the correct default is).
private  void constructColumns()
          Constructs a pair of PaletteColumns: the available and selected options.
protected  void finishLoad()
          Invoked, as a convienience, from BaseComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification)>BaseComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification) 55 .
abstract  org.apache.tapestry.components.Block getAvailableTitleBlock()
           
abstract  org.apache.tapestry.IAsset getDeselectDisabledImage()
           
abstract  org.apache.tapestry.IAsset getDeselectImage()
           
 java.lang.String getDisplayName()
          Returns null, but may make sense to implement a displayName parameter.
abstract  org.apache.tapestry.IAsset getDownDisabledImage()
           
abstract  org.apache.tapestry.IAsset getDownImage()
           
abstract  org.apache.tapestry.IForm getForm()
          Returns the org.apache.tapestry.IForm which contains the component, or null if the component is not contained by a form, of if the containing Form is not currently renderring.
abstract  org.apache.tapestry.form.IPropertySelectionModel getModel()
           
abstract  java.lang.String getName()
          Returns the name of the component, which is automatically generated during renderring.
abstract  int getRows()
           
abstract  org.apache.tapestry.IAsset getSelectDisabledImage()
           
abstract  java.util.List getSelected()
           
abstract  org.apache.tapestry.components.Block getSelectedTitleBlock()
           
abstract  org.apache.tapestry.IAsset getSelectImage()
           
abstract  SortMode getSort()
           
 java.util.Map getSymbols()
           
abstract  org.apache.tapestry.IAsset getUpDisabledImage()
           
abstract  org.apache.tapestry.IAsset getUpImage()
           
private  void handleSubmission(org.apache.tapestry.IRequestCycle cycle)
           
 boolean isDisabled()
          Returns false.
 boolean isSortUser()
           
protected  void renderComponent(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle)
          Renders the top level components contained by the receiver.
private  void runScript(org.apache.tapestry.IRequestCycle cycle)
          Executes the associated script, which generates all the JavaScript to support this Palette.
abstract  void setAvailableColumn(PaletteColumn column)
           
abstract  void setAvailableTitleBlock(org.apache.tapestry.components.Block availableTitleBlock)
           
abstract  void setDeselectDisabledImage(org.apache.tapestry.IAsset deselectDisabledImage)
           
abstract  void setDeselectImage(org.apache.tapestry.IAsset deselectImage)
           
abstract  void setDownDisabledImage(org.apache.tapestry.IAsset downDisabledImage)
           
abstract  void setDownImage(org.apache.tapestry.IAsset downImage)
           
abstract  void setForm(org.apache.tapestry.IForm form)
           
private  void setImage(org.apache.tapestry.html.Body body, org.apache.tapestry.IRequestCycle cycle, java.lang.String symbolName, org.apache.tapestry.IAsset asset)
          Extracts its asset URL, sets it up for preloading, and assigns the preload reference as a script symbol.
abstract  void setName(java.lang.String name)
          Invoked by IForm.getElementId(IFormComponent)>IForm.getElementId(IFormComponent) 55 when a name is created for a form component.
abstract  void setRows(int rows)
           
abstract  void setSelectDisabledImage(org.apache.tapestry.IAsset selectDisabledImage)
           
abstract  void setSelected(java.util.List selected)
           
abstract  void setSelectedColumn(PaletteColumn column)
           
abstract  void setSelectedTitleBlock(org.apache.tapestry.components.Block selectedTitleBlock)
           
abstract  void setSelectImage(org.apache.tapestry.IAsset selectImage)
           
abstract  void setSort(SortMode sort)
           
abstract  void setTableClass(java.lang.String tableClass)
           
abstract  void setUpDisabledImage(org.apache.tapestry.IAsset upDisabledImage)
           
abstract  void setUpImage(org.apache.tapestry.IAsset upImage)
           
 
Methods inherited from class org.apache.tapestry.BaseComponent
addOuter, finishLoad
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, format, format, format, format, formatString, formatString, formatString, formatString, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getChangeObserver, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, pageEndRender, prepareForRender, render, renderBody, renderInformalParameters, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification, toString
 
Methods inherited from class org.apache.hivemind.impl.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, finishLoad, getAsset, getAssets, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, renderBody, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification
 
Methods inherited from interface org.apache.tapestry.IRender
render
 
Methods inherited from interface org.apache.hivemind.LocationHolder
setLocation
 
Methods inherited from interface org.apache.hivemind.Locatable
getLocation
 

Field Detail

DEFAULT_ROWS

private static final int DEFAULT_ROWS
See Also:
Constant Field Values

MAP_SIZE

private static final int MAP_SIZE
See Also:
Constant Field Values

DEFAULT_TABLE_CLASS

private static final java.lang.String DEFAULT_TABLE_CLASS
See Also:
Constant Field Values

_symbols

private java.util.Map _symbols
A set of symbols produced by the Palette script. This is used to provide proper names for some of the HTML elements (<select> and <button> elements, etc.).


_script

private org.apache.tapestry.IScript _script
A cached copy of the script used with the component.

Constructor Detail

Palette

public Palette()
Method Detail

setAvailableColumn

public abstract void setAvailableColumn(PaletteColumn column)
Since:
3.0

setSelectedColumn

public abstract void setSelectedColumn(PaletteColumn column)
Since:
3.0

finishLoad

protected void finishLoad()
Description copied from class: org.apache.tapestry.AbstractComponent
Invoked, as a convienience, from AbstractComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification)>AbstractComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification) 55 . This implemenation does nothing. Subclasses may override without invoking this implementation.


getName

public abstract java.lang.String getName()
Description copied from interface: org.apache.tapestry.form.IFormComponent
Returns the name of the component, which is automatically generated during renderring.

This value is set inside the component's render method and is not cleared. If the component is inside a org.apache.tapestry.components.Foreach, the value returned is the most recent name generated for the component.

This property is made available to facilitate writing JavaScript that allows components (in the client web browser) to interact.

In practice, a org.apache.tapestry.html.Script component works with the org.apache.tapestry.html.Body component to get the JavaScript code inserted and referenced.

Specified by:
getName in interface org.apache.tapestry.form.IFormComponent

setName

public abstract void setName(java.lang.String name)
Description copied from interface: org.apache.tapestry.form.IFormComponent
Invoked by IForm.getElementId(IFormComponent)>IForm.getElementId(IFormComponent) 55 when a name is created for a form component.

Specified by:
setName in interface org.apache.tapestry.form.IFormComponent

getForm

public abstract org.apache.tapestry.IForm getForm()
Description copied from interface: org.apache.tapestry.form.IFormComponent
Returns the org.apache.tapestry.IForm which contains the component, or null if the component is not contained by a form, of if the containing Form is not currently renderring.

Specified by:
getForm in interface org.apache.tapestry.form.IFormComponent

setForm

public abstract void setForm(org.apache.tapestry.IForm form)

renderComponent

protected void renderComponent(org.apache.tapestry.IMarkupWriter writer,
                               org.apache.tapestry.IRequestCycle cycle)
Description copied from class: org.apache.tapestry.BaseComponent
Renders the top level components contained by the receiver.


cleanupAfterRender

protected void cleanupAfterRender(org.apache.tapestry.IRequestCycle cycle)
Description copied from class: org.apache.tapestry.AbstractComponent
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)>AbstractComponent.render(IMarkupWriter, IRequestCycle) 55 after the component renders, to clear any parameters back to null (or 0, or false, or whatever the correct default is). Primarily, this is used to ensure that the component doesn't hold onto any objects that could otherwise be garbage collected.

Subclasses may override this implementation, but must also invoke it.


runScript

private void runScript(org.apache.tapestry.IRequestCycle cycle)
Executes the associated script, which generates all the JavaScript to support this Palette.


setImage

private void setImage(org.apache.tapestry.html.Body body,
                      org.apache.tapestry.IRequestCycle cycle,
                      java.lang.String symbolName,
                      org.apache.tapestry.IAsset asset)
Extracts its asset URL, sets it up for preloading, and assigns the preload reference as a script symbol.


getSymbols

public java.util.Map getSymbols()

constructColumns

private void constructColumns()
Constructs a pair of PaletteColumns: the available and selected options.


handleSubmission

private void handleSubmission(org.apache.tapestry.IRequestCycle cycle)

isSortUser

public boolean isSortUser()

getDisplayName

public java.lang.String getDisplayName()
Returns null, but may make sense to implement a displayName parameter.

Specified by:
getDisplayName in interface org.apache.tapestry.form.IFormComponent

getAvailableTitleBlock

public abstract org.apache.tapestry.components.Block getAvailableTitleBlock()

setAvailableTitleBlock

public abstract void setAvailableTitleBlock(org.apache.tapestry.components.Block availableTitleBlock)

getDeselectDisabledImage

public abstract org.apache.tapestry.IAsset getDeselectDisabledImage()

setDeselectDisabledImage

public abstract void setDeselectDisabledImage(org.apache.tapestry.IAsset deselectDisabledImage)

getDeselectImage

public abstract org.apache.tapestry.IAsset getDeselectImage()

setDeselectImage

public abstract void setDeselectImage(org.apache.tapestry.IAsset deselectImage)

getDownDisabledImage

public abstract org.apache.tapestry.IAsset getDownDisabledImage()

setDownDisabledImage

public abstract void setDownDisabledImage(org.apache.tapestry.IAsset downDisabledImage)

getDownImage

public abstract org.apache.tapestry.IAsset getDownImage()

setDownImage

public abstract void setDownImage(org.apache.tapestry.IAsset downImage)

getModel

public abstract org.apache.tapestry.form.IPropertySelectionModel getModel()

getRows

public abstract int getRows()

setRows

public abstract void setRows(int rows)

getSelectDisabledImage

public abstract org.apache.tapestry.IAsset getSelectDisabledImage()

setSelectDisabledImage

public abstract void setSelectDisabledImage(org.apache.tapestry.IAsset selectDisabledImage)

getSelectedTitleBlock

public abstract org.apache.tapestry.components.Block getSelectedTitleBlock()

setSelectedTitleBlock

public abstract void setSelectedTitleBlock(org.apache.tapestry.components.Block selectedTitleBlock)

getSelectImage

public abstract org.apache.tapestry.IAsset getSelectImage()

setSelectImage

public abstract void setSelectImage(org.apache.tapestry.IAsset selectImage)

getSort

public abstract SortMode getSort()

setSort

public abstract void setSort(SortMode sort)

setTableClass

public abstract void setTableClass(java.lang.String tableClass)

getUpDisabledImage

public abstract org.apache.tapestry.IAsset getUpDisabledImage()

setUpDisabledImage

public abstract void setUpDisabledImage(org.apache.tapestry.IAsset upDisabledImage)

getUpImage

public abstract org.apache.tapestry.IAsset getUpImage()

setUpImage

public abstract void setUpImage(org.apache.tapestry.IAsset upImage)

isDisabled

public boolean isDisabled()
Returns false. Palette components are never disabled.

Specified by:
isDisabled in interface org.apache.tapestry.form.IFormComponent
Since:
2.2

getSelected

public abstract java.util.List getSelected()
Since:
2.2

setSelected

public abstract void setSelected(java.util.List selected)
Since:
2.2