com.vaadin.client.ui.grid.renderers
Class WidgetRenderer<T,W extends Widget>

java.lang.Object
  extended by com.vaadin.client.ui.grid.renderers.ComplexRenderer<T>
      extended by com.vaadin.client.ui.grid.renderers.WidgetRenderer<T,W>
Type Parameters:
T - the row data type
W - the Widget type
All Implemented Interfaces:
Renderer<T>
Direct Known Subclasses:
ButtonRenderer, ImageRenderer, ProgressBarRenderer

public abstract class WidgetRenderer<T,W extends Widget>
extends ComplexRenderer<T>

A renderer for rendering widgets into cells.

Since:
Author:
Vaadin Ltd

Constructor Summary
WidgetRenderer()
           
 
Method Summary
abstract  W createWidget()
          Creates a widget to attach to a cell.
protected static Cell getCell(NativeEvent event)
          Returns the cell instance corresponding to the element that the given event originates from.
protected  W getWidget(Element e)
           
 void init(FlyweightCell cell)
          Called at initialization stage.
 void render(FlyweightCell cell, T data)
          Called whenever the Grid updates a cell
abstract  void render(FlyweightCell cell, T data, W widget)
          Renders a cell with a widget.
 
Methods inherited from class com.vaadin.client.ui.grid.renderers.ComplexRenderer
destroy, destroy, getConsumedEvents, onActivate, onBrowserEvent, setContentVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WidgetRenderer

public WidgetRenderer()
Method Detail

init

public void init(FlyweightCell cell)
Description copied from class: ComplexRenderer
Called at initialization stage. Perform any initialization here e.g. attach handlers, attach widgets etc.

Specified by:
init in class ComplexRenderer<T>
Parameters:
cell - The cell. Note that the cell is not to be stored outside of the method as the cell install will change. See FlyweightCell

createWidget

public abstract W createWidget()
Creates a widget to attach to a cell. The widgets will be attached to the cell after the cell element has been attached to DOM.

Returns:
widget to attach to a cell. All returned instances should be new widget instances without a parent.

render

public void render(FlyweightCell cell,
                   T data)
Description copied from interface: Renderer
Called whenever the Grid updates a cell

Parameters:
cell - The cell. Note that the cell is a flyweight and should not be stored outside of the method as it will change.
data - The column data object

render

public abstract void render(FlyweightCell cell,
                            T data,
                            W widget)
Renders a cell with a widget. This provides a way to update any information in the widget that is cell specific. Do not detach the Widget here, it will be done automatically by the Grid when the widget is no longer needed.

Parameters:
cell - the cell to render
data - the data of the cell
widget - the widget embedded in the cell

getWidget

protected W getWidget(Element e)

getCell

protected static Cell getCell(NativeEvent event)
Returns the cell instance corresponding to the element that the given event originates from. If the event does not originate from a grid cell, returns null.

Parameters:
event - the event
Returns:
the cell or null if no such cell


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.