public void encodeOneRow(FacesContext context, TableHolder holder)
throws IOException {
ResponseWriter writer = context.getResponseWriter();
OrderingListRendererTableHolder tableHolder = (OrderingListRendererTableHolder) holder;
UIOrderingList table = (UIOrderingList) holder.getTable();
String clientId = holder.getTable().getClientId(context);
writer.startElement(HTML.TR_ELEMENT, table);
writer.writeAttribute("id", clientId, null);
StringBuffer rowClassName = new StringBuffer("rich-ordering-list-row");
String rowClass = holder.getRowClass();
if (rowClass != null) {
rowClassName.append(' ');
rowClassName.append(rowClass);
}
StringBuffer cellClassName = new StringBuffer("rich-ordering-list-cell");
ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
ItemState state = getItemState(context, table, variables);
boolean active = state.isActive();
// if (active) {
// rowClassName.append(" rich-ordering-list-row-active");
// cellClassName.append(" rich-ordering-list-cell-active");
// }
boolean selected = state.isSelected();
if (selected) {
rowClassName.append(" rich-ordering-list-row-selected");
cellClassName.append(" rich-ordering-list-cell-selected");
}
SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
selectionState.addState(selected);
writer.writeAttribute("class", rowClassName.toString(), null);
boolean columnRendered = false;
int colCounter = 0;
for (Iterator iterator = table.columns(); iterator.hasNext();) {
UIComponent component = (UIComponent) iterator.next();
if (component.isRendered()) {
writer.startElement(HTML.td_ELEM, table);
//if (!iterator.hasNext()) {
// cellClassName.append(" rich-ordering-list-cell-end");
//}
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.write(" ");
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.id_ATTRIBUTE, clientId + "StateInput", null);
writer.writeAttribute(HTML.autocomplete_ATTRIBUTE, "off", null);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, 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(tableHolder.getConverter().getAsString(context, table, table.getRowData()));
writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
writer.endElement(HTML.INPUT_ELEM);