|
GWT 2.1.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
C - the type that this Cell representspublic interface Cell<C>
A light weight representation of a renderable object.
public class CellExample implements EntryPoint {
/**
* A custom {@link Cell} used to render a string that contains the name of a
* color.
*/
private static class ColorCell extends AbstractCell<String> {
@Override
public void render(String value, Object key, SafeHtmlBuilder sb) {
/*
* Always do a null check on the value. Cell widgets can pass null to
* cells if the underlying data contains a null, or if the data arrives
* out of order.
*/
if (value == null) {
return;
}
// If the value comes from the user, we escape it to avoid XSS attacks.
SafeHtml safeValue = SafeHtmlUtils.fromString(value);
// Append some HTML that sets the text color.
sb.appendHtmlConstant("<div style=\"color:" + safeValue.asString()
+ "\">");
sb.append(safeValue);
sb.appendHtmlConstant("</div>");
}
}
/**
* The list of data to display.
*/
private static final List<String> COLORS = Arrays.asList("red", "green",
"blue", "violet", "black", "gray");
public void onModuleLoad() {
// Create a cell to render each value.
ColorCell cell = new ColorCell();
// Use the cell in a CellList.
CellList<String> cellList = new CellList<String>(cell);
// Push the data into the widget.
cellList.setRowData(0, COLORS);
// Add it to the root panel.
RootPanel.get().add(cellList);
}
}
| Method Summary | |
|---|---|
boolean |
dependsOnSelection()
Check if this cell depends on the selection state. |
java.util.Set<java.lang.String> |
getConsumedEvents()
Get the set of events that this cell consumes. |
boolean |
handlesSelection()
Check if this cell handles selection. |
boolean |
isEditing(Element parent,
C value,
java.lang.Object key)
Returns true if the cell is currently editing the data identified by the given element and key. |
void |
onBrowserEvent(Element parent,
C value,
java.lang.Object key,
NativeEvent event,
ValueUpdater<C> valueUpdater)
Handle a browser event that took place within the cell. |
void |
render(C value,
java.lang.Object key,
SafeHtmlBuilder sb)
Render a cell as HTML into a SafeHtmlBuilder, suitable for passing
to Element.setInnerHTML(java.lang.String) on a container element. |
boolean |
resetFocus(Element parent,
C value,
java.lang.Object key)
Reset focus on the Cell. |
void |
setValue(Element parent,
C value,
java.lang.Object key)
This method may be used by cell containers to set the value on a single cell directly, rather than using Element.setInnerHTML(String). |
| Method Detail |
|---|
boolean dependsOnSelection()
java.util.Set<java.lang.String> getConsumedEvents()
onBrowserEvent(Element, Object, Object, NativeEvent, ValueUpdater).
The returned value should not be modified, and may be an unmodifiable set. Changes to the return value may not be reflected in the cell.
boolean handlesSelection()
boolean isEditing(Element parent,
C value,
java.lang.Object key)
parent - the parent Elementvalue - the value associated with the cellkey - the unique key associated with the row object
void onBrowserEvent(Element parent,
C value,
java.lang.Object key,
NativeEvent event,
ValueUpdater<C> valueUpdater)
parent - the parent Elementvalue - the value associated with the cellkey - the unique key associated with the row objectevent - the native browser eventvalueUpdater - a ValueUpdater, or null if not specified
void render(C value,
java.lang.Object key,
SafeHtmlBuilder sb)
SafeHtmlBuilder, suitable for passing
to Element.setInnerHTML(java.lang.String) on a container element.
Note: If your cell contains natively focusable elements, such as buttons or input elements, be sure to set the tabIndex to -1 so that they do not steal focus away from the containing widget.
value - the cell value to be renderedkey - the unique key associated with the row objectsb - the SafeHtmlBuilder to be written to
boolean resetFocus(Element parent,
C value,
java.lang.Object key)
parent - the parent Elementvalue - the value associated with the cellkey - the unique key associated with the row object
void setValue(Element parent,
C value,
java.lang.Object key)
Element.setInnerHTML(String). See
AbstractCell.setValue(Element, Object, Object) for a default
implementation that uses render(Object, Object, SafeHtmlBuilder).
parent - the parent Elementvalue - the value associated with the cellkey - the unique key associated with the row object
|
GWT 2.1.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||