net.codescore.ui.components.list
Class ZKObjectList<T>

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zul.impl.XulElement
              extended by org.zkoss.zul.Window
                  extended by net.codescore.ui.components.list.ZKObjectList<T>
Type Parameters:
T - The object type for the list
All Implemented Interfaces:
Serializable, Cloneable, Component, IdSpace, ComponentCtrl
Direct Known Subclasses:
AbstractDropDown

public class ZKObjectList<T>
extends Window

This class provides a strong framework for quickly generating a list of objects. This list can generate a table style list, or a select element.
For creating an HTML select control, use the AbstractDropDown class.
This class relies on an external renderer class to render each cell in the table, and must be initialized correctly, please see an example implementation, such as the DynamicScoreBoard which uses this class to generate the score board.

Author:
Adam Cornett
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.zkoss.zul.Window
Window.ExtraCtrl
 
Field Summary
protected  Window callBackWin
          This window is passed to the onSelect event for use by the renderer's doActionmethod.
protected  List<T> data
           
private  Listhead head
           
protected  List<T> initData
           
protected  Listbox list
           
private  ListModelList model
           
protected  AbstractRenderer<T> renderer
          This is the renderer used to render the list, it also handles sorting and onSelect events
private static long serialVersionUID
           
private  String windowTitle
           
 
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
RS_NO_DISPLAY, RS_NO_HEIGHT, RS_NO_WIDTH
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Constructor Summary
ZKObjectList()
          Default constructor
ZKObjectList(boolean noForward)
           
ZKObjectList(List<T> l, AbstractRenderer<T> ren)
           
ZKObjectList(String title)
           
ZKObjectList(String title, boolean noForward)
           
ZKObjectList(String title, List<T> l, AbstractRenderer<T> ren)
           
 
Method Summary
 void addListForward(String orgEvent, Component target, String targetEvent)
          Adds a forward for the list's onSelect event
 Window getCallbackWin()
           
 T getListSelected()
          Returns the selected item in the list.
 String getWindowTitle()
           
 void initListModel()
          initalizes the list model
 void initListModel(List<T> l)
          initalizes the list model
 void initRenderer(AbstractRenderer<T> r)
          Initalizes the item renderer
 void onSelect()
           
 void reLoadList(List<T> l)
          reloads the list data
 void removeObject(DataObject l)
          removes and object from the list and the database
 void setCallbackWin(Window oah)
           
protected  void setList(List<T> l)
          Sets the data to be rendered
 void setListMold(String mold)
          Sets the list's 'mold' attribute
 void setListWidth(String width)
           
 void setSelected(T obj)
           
 void setWindowTitle(String windowTitle)
           
 void sort(int colNum)
           
 
Methods inherited from class org.zkoss.zul.Window
clone, doEmbedded, doHighlighted, doModal, doOverlapped, doPopup, getBorder, getCaption, getContentSclass, getContentStyle, getCtrlKeys, getDefaultActionOnShow, getMode, getOuterAttrs, getPosition, getRealStyle, getSclass, getTitle, getTitleSclass, inEmbedded, inHighlighted, inModal, inOverlapped, inPopup, insertBefore, isClosable, isSizable, newExtraCtrl, onChildRemoved, onClose, onModal, setBorder, setClosable, setContentSclass, setContentStyle, setCtrlKeys, setDefaultActionOnShow, setDraggable, setMode, setMode, setPage, setParent, setPosition, setSclass, setSizable, setTitle, setVisible
 
Methods inherited from class org.zkoss.zul.impl.XulElement
getAction, getActionAttrs, getAllOnClickAttrs, getContext, getInnerAttrs, getPopup, getTooltip, setAction, setContext, setContext, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
focus, getAllOnClickAttrs, getDraggable, getDroppable, getHeight, getLeft, getRealSclass, getRealStyleFlags, getStyle, getTooltiptext, getTop, getWidth, getZIndex, setClass, setDroppable, setFocus, setHeight, setLeft, setStyle, setTooltiptext, setTop, setWidth, setZIndex
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addEventHandler, addEventListener, addForward, addForward, addMoved, addSharedAnnotationMap, addSharedEventHandlerMap, appendAsapAttr, appendAsapAttr, appendChild, applyProperties, containsVariable, detach, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getCommand, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getExtraCtrl, getFellow, getFellowIfAny, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getMoldURI, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getPropagatee, getRoot, getSpaceOwner, getUuid, getVariable, invalidate, isAsapRequired, isChildable, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onDrawNewChild, onPageAttached, onPageDetached, onWrongValue, redraw, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setComponentDefinition, setId, setMold, setPageBefore, setVariable, smartUpdate, smartUpdate, smartUpdate, smartUpdateDeferred, smartUpdateValues, toString, unsetVariable
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zkoss.zk.ui.IdSpace
getFellow, getFellowIfAny
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

head

private Listhead head

model

private ListModelList model

windowTitle

private String windowTitle

callBackWin

protected Window callBackWin
This window is passed to the onSelect event for use by the renderer's doActionmethod.


data

protected List<T> data

initData

protected List<T> initData

list

protected Listbox list

renderer

protected AbstractRenderer<T> renderer
This is the renderer used to render the list, it also handles sorting and onSelect events

Constructor Detail

ZKObjectList

public ZKObjectList()
Default constructor


ZKObjectList

public ZKObjectList(boolean noForward)
Parameters:
noForward - If true, the constructor will not set a handler for the list's onSelect event.

ZKObjectList

public ZKObjectList(List<T> l,
                    AbstractRenderer<T> ren)
Parameters:
l - the list of objects to be rendered
ren - the renderer the list should use

ZKObjectList

public ZKObjectList(String title)
Parameters:
title - This window's title Window.setTitle(String)

ZKObjectList

public ZKObjectList(String title,
                    boolean noForward)
Parameters:
title - This window's title Window.setTitle(String)
noForward - If true, the constructor will not set a handler for the list's onSelect event.

ZKObjectList

public ZKObjectList(String title,
                    List<T> l,
                    AbstractRenderer<T> ren)
Parameters:
title - This window's title Window.setTitle(String)
l - the list of objects to be rendered
ren - the renderer the list should use
Method Detail

addListForward

public void addListForward(String orgEvent,
                           Component target,
                           String targetEvent)
Adds a forward for the list's onSelect event

Parameters:
orgEvent -
target -
targetEvent -
See Also:
Component.addForward(String, Component, String)

getCallbackWin

public Window getCallbackWin()

getListSelected

public T getListSelected()
Returns the selected item in the list. If not item is selected, the first item in the list is returned

Returns:

getWindowTitle

public String getWindowTitle()

initListModel

public final void initListModel()
initalizes the list model


initListModel

public final void initListModel(List<T> l)
initalizes the list model

Parameters:
l - the list to use
See Also:
setList(List)

initRenderer

public final void initRenderer(AbstractRenderer<T> r)
Initalizes the item renderer

Parameters:
r - the renderer to be used by the list

onSelect

public void onSelect()

reLoadList

public void reLoadList(List<T> l)
reloads the list data

Parameters:
l - the new data to be rendered

removeObject

public final void removeObject(DataObject l)
removes and object from the list and the database

Parameters:
l - object to be removed

setCallbackWin

public void setCallbackWin(Window oah)

setListMold

public void setListMold(String mold)
Sets the list's 'mold' attribute

Parameters:
mold -
See Also:
Component.setMold(String)

setListWidth

public void setListWidth(String width)

setSelected

public void setSelected(T obj)

setWindowTitle

public void setWindowTitle(String windowTitle)

sort

public void sort(int colNum)

setList

protected void setList(List<T> l)
Sets the data to be rendered

Parameters:
l -


Copyright 2008 © Adam Cornett, Andrew Conner All Rights Reserved.