return stringWriter.getBuffer().toString();
}
public void encodeOneRow(FacesContext context, TableHolder holder)
throws IOException {
UIListShuttle table = (UIListShuttle) holder.getTable();
ListShuttleRendererTableHolder shuttleRendererTableHolder = (ListShuttleRendererTableHolder) holder;
ListShuttleRowKey listShuttleRowKey = (ListShuttleRowKey) table.getRowKey();
if (listShuttleRowKey != null) {
boolean source = shuttleRendererTableHolder.isSource();
if (source == listShuttleRowKey.isFacadeSource()) {
ResponseWriter writer = context.getResponseWriter();
String clientId = table.getClientId(context);
writer.startElement(HTML.TR_ELEMENT, table);
writer.writeAttribute("id", clientId, null);
StringBuffer rowClassName = new StringBuffer();
StringBuffer cellClassName = new StringBuffer();
if (source) {
rowClassName.append("rich-shuttle-source-row");
cellClassName.append("rich-shuttle-source-cell");
} else {
rowClassName.append("rich-shuttle-target-row");
cellClassName.append("rich-shuttle-target-cell");
}
String rowClass = holder.getRowClass();
if (rowClass != null) {
rowClassName.append(' ');
rowClassName.append(rowClass);
}
ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
ItemState itemState = getItemState(context, table, variables);
boolean active = itemState.isActive();
boolean selected = itemState.isSelected();
selectionState.addState(selected);
if (selected) {
if (source) {
rowClassName.append(" rich-shuttle-source-row-selected");
cellClassName.append(" rich-shuttle-source-cell-selected");
} else {
rowClassName.append(" rich-shuttle-target-row-selected");
cellClassName.append(" rich-shuttle-target-cell-selected");
}
}
writer.writeAttribute("class", rowClassName.toString(), null);
int colCounter = 0;
boolean columnRendered = false;
for (Iterator iterator = table.columns(); iterator.hasNext();) {
UIComponent component = (UIComponent) iterator.next();
if (component.isRendered()) {
writer.startElement(HTML.td_ELEM, table);
Object width = component.getAttributes().get("width");
if (width != null) {
writer.writeAttribute("style", "width: " + HtmlUtil.qualifySize(width.toString()), null);
}
String columnClass = holder.getColumnClass(colCounter);
if (columnClass != null) {
writer.writeAttribute("class", cellClassName.toString().concat(" " + columnClass), null);
} else {
writer.writeAttribute("class", cellClassName.toString(), null);
}
writer.startElement(HTML.IMG_ELEMENT, table);
writer.writeAttribute(HTML.src_ATTRIBUTE, getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null), null);
writer.writeAttribute(HTML.style_ATTRIBUTE, "width:1px;height:1px;", null);
writer.writeAttribute(HTML.alt_ATTRIBUTE, " ", null);
writer.endElement(HTML.IMG_ELEMENT);
renderChildren(context, component);
if (!columnRendered) {
writer.startElement(HTML.INPUT_ELEM, table);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
writer.writeAttribute(HTML.autocomplete_ATTRIBUTE, "off", null);
writer.writeAttribute(HTML.NAME_ATTRIBUTE, table.getBaseClientId(context), null);
StringBuffer value = new StringBuffer();
if (selected) {
value.append('s');
}
if (active) {
value.append('a');
}
value.append(table.getRowKey());
value.append(':');
value.append(shuttleRendererTableHolder.getConverter().getAsString(context, table, table.getRowData()));
writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + "StateInput", null);