Author: abelevich
Date: 2010-06-24 10:18:53 -0400 (Thu, 24 Jun 2010)
New Revision: 17668
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableDataIterator.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableFixedChildrenIterator.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
Log:
small code clean up
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableDataIterator.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableDataIterator.java 2010-06-24
14:10:07 UTC (rev 17667)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableDataIterator.java 2010-06-24
14:18:53 UTC (rev 17668)
@@ -44,23 +44,15 @@
UIComponent nextColumn = null;
while (nextColumn == null && childrenIterator.hasNext()) {
UIComponent child = childrenIterator.next();
- // TODO nick - why non-rendered children are filtered?
- // TODO nick - should be (child instanceof UIColumn || child instanceof
Column)?
if ((child instanceof UIColumn) || (child instanceof Column)) {
nextColumn = child;
- } else if (checkAjaxComponent(child)) {
- nextColumn = child;
- }
+ }
}
// TODO nick - free childrenIterator
- // ???
while (nextColumn == null && facetsIterator.hasNext()) {
- UIComponent component = facetsIterator.next();
- if (checkAjaxComponent(component)) {
- nextColumn = component;
- }
+ nextColumn = facetsIterator.next();
}
// TODO nick - free facetsIterator
@@ -76,9 +68,4 @@
return this.childrenIterator;
}
- // TODO nick - what's this for?
- protected boolean checkAjaxComponent(UIComponent child) {
- return false;
- }
-
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableFixedChildrenIterator.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableFixedChildrenIterator.java 2010-06-24
14:10:07 UTC (rev 17667)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableFixedChildrenIterator.java 2010-06-24
14:18:53 UTC (rev 17668)
@@ -50,9 +50,7 @@
if ((child instanceof UIColumn) && child.isRendered()) {
currentColumnIterator = getChildFacetIterator(child);
next = nextItem();
- } else if (checkAjaxComponent(child)) {
- next = child;
- }
+ }
}
}
@@ -64,8 +62,7 @@
protected UIComponent getNextFacet() {
Iterator<UIComponent> facetsIterator = getFacetsIterator();
- // TODO nick - while -> if
- while (facetsIterator.hasNext()) {
+ if(facetsIterator.hasNext()) {
return facetsIterator.next();
}
return null;
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-06-24
14:10:07 UTC (rev 17667)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-06-24
14:18:53 UTC (rev 17668)
@@ -92,11 +92,11 @@
}
public UIComponent getHeader() {
- return getFacet("header");
+ return getFacet(HEADER);
}
public UIComponent getFooter() {
- return getFacet("footer");
+ return getFacet(FOOTER);
}
public UIComponent getNoData() {
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-06-24
14:10:07 UTC (rev 17667)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-06-24
14:18:53 UTC (rev 17668)
@@ -41,7 +41,12 @@
public static final String MODE_SERVER = "server";
public static final String MODE_CLIENT = "client";
+
+ public static final int EXPAND_STATE = 1;
+
+ public static final int COLLAPSE_STATE = 0;
+
enum PropertyKeys {
expandMode, expanded, toggleExpression
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2010-06-24
14:10:07 UTC (rev 17667)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2010-06-24
14:18:53 UTC (rev 17668)
@@ -56,6 +56,7 @@
} catch (IOException e) {
throw new FacesException(e);
}
+
holder.nextRow();
return DataVisitResult.CONTINUE;
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2010-06-24
14:10:07 UTC (rev 17667)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2010-06-24
14:18:53 UTC (rev 17668)
@@ -51,13 +51,7 @@
public static final String BREAK_ROW_BEFORE = "breakRowBefore";
- public static final String ROWSPAN_STRING = "rowspan";
-
- public static final String COLSPAN_STRING = "colspan";
-
-
public void encodeColumn(FacesContext context, ResponseWriter writer, UIColumn
component, RowHolder rowHolder) throws IOException {
-
String parentId = rowHolder.getParentClientId();
if (component instanceof org.richfaces.component.UIColumn) {
@@ -71,11 +65,13 @@
if (rowHolder.isRowStart()) {
int currentRow = rowHolder.getCurrentRow();
+
if (rowHolder.getCurrentRow() == 0) {
encodeFirstRowStart(writer, context, parentId, currentRow, component);
} else {
encodeRowStart(writer, context, parentId, currentRow, component);
}
+
rowHolder.setRowStart(false);
}
@@ -96,14 +92,14 @@
if (component instanceof org.richfaces.component.UIColumn) {
Map<String, Object> attributes = component.getAttributes();
- int rowspan = (Integer) attributes.get(ROWSPAN_STRING);
+ int rowspan = (Integer) attributes.get(HTML.ROWSPAN_ATTRIBUTE);
if (rowspan != Integer.MIN_VALUE) {
- writer.writeAttribute(ROWSPAN_STRING, Integer.valueOf(rowspan), null);
+ writer.writeAttribute(HTML.ROWSPAN_ATTRIBUTE, Integer.valueOf(rowspan),
null);
}
- int colspan = (Integer) attributes.get(COLSPAN_STRING);
+ int colspan = (Integer) attributes.get(HTML.COLSPAN_ATTRIBUTE);
if (colspan != Integer.MIN_VALUE) {
- writer.writeAttribute(COLSPAN_STRING, Integer.valueOf(colspan), null);
+ writer.writeAttribute(HTML.COLSPAN_ATTRIBUTE, Integer.valueOf(colspan),
null);
}
}
}
@@ -237,7 +233,7 @@
}
currentLength = 0;
}
- Integer colspan = (Integer) attributes.get(COLSPAN_STRING);
+ Integer colspan = (Integer) attributes.get(HTML.COLSPAN_ATTRIBUTE);
// Append colspan of this column
if (null != colspan && colspan.intValue() !=
Integer.MIN_VALUE) {
currentLength += colspan.intValue();
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-24
14:10:07 UTC (rev 17667)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-24
14:18:53 UTC (rev 17668)
@@ -102,7 +102,7 @@
}
protected boolean isEncodeHeaders(UIDataTableBase table) {
- return table.isColumnFacetPresent("header") ||
isColumnAttributeSet(table, "sortBy")
+ return table.isColumnFacetPresent(UIDataTableBase.HEADER) ||
isColumnAttributeSet(table, "sortBy")
|| isColumnAttributeSet(table, "comparator")
|| isColumnAttributeSet(table, "filterBy");
}
@@ -163,7 +163,7 @@
writer.startElement(HTML.TR_ELEMENT, dataTableBase);
writer.startElement(HTML.TD_ELEM, dataTableBase);
- writer.writeAttribute("colspan", columns, null);
+ writer.writeAttribute(HTML.COLSPAN_ATTRIBUTE, columns, null);
String styleClass = (String)
dataTableBase.getAttributes().get("noDataStyleClass");
styleClass = styleClass != null ? getNoDataClass() + " " +
styleClass : getNoDataClass();
@@ -270,7 +270,7 @@
writer.startElement(HTML.TFOOT_ELEMENT, dataTable);
writer.writeAttribute(HTML.ID_ATTRIBUTE, footerClientId, null);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-tfoot",
null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rd-dt-tfoot",
null);
}
int columns = getColumnsCount(dataTable);
@@ -301,7 +301,7 @@
writer.writeAttribute(HTML.ID_ATTRIBUTE, targetId, null);
encodeStyleClass(writer, facesContext, dataTable, null, rowClass);
- encodeColumnFacet(facesContext, writer, dataTable,
"footer",columns, cellClass);
+ encodeColumnFacet(facesContext, writer, dataTable,
UIDataTableBase.FOOTER,columns, cellClass);
writer.endElement(HTML.TR_ELEMENT);
if (encodePartialUpdateForChildren) {
@@ -320,7 +320,7 @@
firstClass = mergeStyleClasses("footerFirstClass", firstClass,
dataTable);
// TODO nick - rename method "encodeTableHeaderFacet"
saveRowStyles(facesContext, id, firstClass, rowClass, cellClass);
- encodeTableFacet(facesContext, writer, id, columns, footer,
"footer", rowClass, cellClass,
+ encodeTableFacet(facesContext, writer, id, columns, footer,
UIDataTableBase.FOOTER, rowClass, cellClass,
encodePartialUpdateForChildren);
}
@@ -367,7 +367,7 @@
writer.startElement(HTML.THEAD_ELEMENT, dataTable);
writer.writeAttribute(HTML.ID_ATTRIBUTE, headerClientId, null);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-thead",
null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rf-dt-thead",
null);
}
int columns = getColumnsCount(dataTable);
@@ -386,11 +386,12 @@
firstClass = mergeStyleClasses("headerFirstClass", firstClass,
dataTable);
saveRowStyles(facesContext, id, firstClass, rowClass, cellClass);
- encodeTableFacet(facesContext, writer, id, columns, header,
"header", rowClass, cellClass,
+ encodeTableFacet(facesContext, writer, id, columns, header,
UIDataTableBase.HEADER, rowClass, cellClass,
encodePartialUpdateForChildren);
}
if (isEncodeHeaders) {
+
String rowClass = getColumnHeaderSkinClass();
String cellClass = getColumnHeaderCellSkinClass();
String firstClass = getColumnHeaderFirstSkinClass();
@@ -411,7 +412,7 @@
encodeStyleClass(writer, facesContext, dataTable, null, rowClass);
- encodeColumnFacet(facesContext, writer, dataTable, "header",
columns, cellClass);
+ encodeColumnFacet(facesContext, writer, dataTable,
UIDataTableBase.HEADER, columns, cellClass);
writer.endElement(HTML.TR_ELEMENT);
if (encodePartialUpdateForChildren) {
@@ -431,7 +432,6 @@
}
protected void encodeColumnFacet(FacesContext context, ResponseWriter writer,
UIDataTableBase dataTableBase, String facetName, int colCount, String cellClass) throws
IOException {
-
int tColCount = 0;
String id = dataTableBase.getClientId(context);
String element = getCellElement(context, id);
@@ -446,7 +446,7 @@
continue;
}
- Integer colspan = (Integer) column.getAttributes().get("colspan");
+ Integer colspan = (Integer)
column.getAttributes().get(HTML.COLSPAN_ATTRIBUTE);
if (colspan != null && colspan.intValue() > 0) {
tColCount += colspan.intValue();
} else {
@@ -461,8 +461,8 @@
encodeStyleClass(writer, context, column, null, cellClass);
- writer.writeAttribute("scope", "col", null);
- getUtils().encodeAttribute(context, column, "colspan");
+ writer.writeAttribute(HTML.SCOPE_ATTRIBUTE, HTML.COL_ELEMENT, null);
+ getUtils().encodeAttribute(context, column, HTML.COLSPAN_ATTRIBUTE);
EncodeStrategy strategy = getHeaderEncodeStrategy(column, facetName);
if(strategy != null) {
@@ -504,10 +504,10 @@
encodeStyleClass(writer, facesContext, footer, null, cellClass);
if (columns > 0) {
- writer.writeAttribute("colspan", String.valueOf(columns),
null);
+ writer.writeAttribute(HTML.COLSPAN_ATTRIBUTE, String.valueOf(columns),
null);
}
- writer.writeAttribute("scope", "colgroup", null);
+ writer.writeAttribute(HTML.SCOPE_ATTRIBUTE, HTML.COLGROUP_ELEMENT, null);
}
if (encodePartialUpdate && !partialUpdateEncoded) {
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-24
14:10:07 UTC (rev 17667)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-24
14:18:53 UTC (rev 17668)
@@ -42,6 +42,7 @@
import org.richfaces.component.UIDataTable;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.UISubTable;
+import org.richfaces.component.util.HtmlUtil;
/**
* @author Anton Belevich
@@ -74,10 +75,9 @@
public void begin(ResponseWriter writer, FacesContext context, UIComponent
component, Object [] params) throws IOException {
org.richfaces.component.UIColumn column = (org.richfaces.component.UIColumn)
component;
- writer.writeAttribute("id", column.getClientId(context), null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, column.getClientId(context), null);
- boolean sortableColumn = isSortable(column);
- if (sortableColumn) {
+ if (isSortable(column)) {
//TODO :anton -> should component be selfSorted
writer.startElement(HTML.SPAN_ELEM, column);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
"rich-table-sortable-header", null);
@@ -94,26 +94,27 @@
public void encodeTableStructure(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable)
throws IOException {
-
if (dataTable instanceof UIDataTable) {
encodeCaption(writer, context, (UIDataTable) dataTable);
// TODO nick - do we need this element if "columnsWidth" is
absent?
- // TODO nick - use constants from HTML class for attribute/element names
- writer.startElement("colgroup", dataTable);
+ writer.startElement(HTML.COLGROUP_ELEMENT, dataTable);
+
int columns = getColumnsCount(dataTable);
-
writer.writeAttribute(HTML.SPAN_ELEM, String.valueOf(columns), null);
String columnsWidth = (String)
dataTable.getAttributes().get("columnsWidth");
- if (null != columnsWidth) {
+ if (columnsWidth != null) {
+
String[] widths = columnsWidth.split(",");
for (int i = 0; i < widths.length; i++) {
- writer.startElement("col", dataTable);
- writer.writeAttribute("width", widths[i], null);
- writer.endElement("col");
+ writer.startElement(HTML.COL_ELEMENT, dataTable);
+ writer.writeAttribute(HTML.WIDTH_ATTRIBUTE, widths[i], null);
+ writer.endElement(HTML.COL_ELEMENT);
}
+
}
- writer.endElement("colgroup");
+
+ writer.endElement(HTML.COLGROUP_ELEMENT);
}
}
@@ -139,7 +140,6 @@
public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase
holder) throws IOException {
-
RowHolder rowHolder = (RowHolder) holder;
Row row = rowHolder.getRow();
@@ -153,38 +153,35 @@
Iterator<UIComponent> components = row.columns();
while (components.hasNext()) {
-
+
UIComponent child = components.next();
if(child instanceof Row) {
boolean isSubtable = (child instanceof UISubTable);
//new row -> close </tr>
if (rowHolder.getProcessCell() != 0) {
encodeRowEnd(writer);
- //only SubTables could have <tbody>
+
if(isSubtable) {
encodeTableBodyEnd(writer);
tbodyStart = false;
+
if (partialUpdate) {
partialEnd(facesContext);
}
- }
+ }
}
rowHolder.nextCell();
- if(isSubtable){
+ if(isSubtable && partialUpdate){
String id = dataTable.getRelativeClientId(facesContext) +
":"+ child.getId() +":c";
- if(partialUpdate) {
- partialStart(facesContext, id);
- }
+ partialStart(facesContext, id);
}
child.encodeAll(facesContext);
- if (isSubtable) {
- if(partialUpdate) {
- partialEnd(facesContext);
- }
+ if (isSubtable && partialUpdate) {
+ partialEnd(facesContext);
}
} else if(child instanceof UIColumn) {
@@ -193,6 +190,7 @@
if (partialUpdate) {
partialStart(facesContext,
dataTable.getRelativeClientId(facesContext) + ":tb");
}
+
encodeTableBodyStart(writer, facesContext, dataTable);
rowHolder.setRowStart(true);
tbodyStart = true;
@@ -206,6 +204,7 @@
if(!parentTbodyStart && tbodyStart) {
encodeTableBodyEnd(writer);
tbodyStart = false;
+
if(partialUpdate) {
partialEnd(facesContext);
}
@@ -226,35 +225,20 @@
}
protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- if (!shouldProceed(component)) {
- return;
- }
-
UIDataTableBase dataTable = (UIDataTableBase) component;
encodeTableStart(writer, context, dataTable);
encodeTableFacets(writer, context, dataTable);
}
protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- if (!shouldProceed(component)) {
- return;
- }
-
- if (component instanceof UIDataTable) {
- encodeTableEnd(writer);
- }
+ encodeTableEnd(writer);
}
- protected boolean shouldProceed(UIComponent component) {
- return component instanceof UIDataTableBase;
- }
-
protected Class<? extends UIComponent> getComponentClass() {
return UIDataTable.class;
}
public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTable
dataTable) throws IOException {
-
UIComponent caption = dataTable.getCaption();
if (caption == null) {
@@ -269,12 +253,11 @@
String captionClass = (String)
dataTable.getAttributes().get("captionClass");
String captionSkinClass = getCaptionSkinClass();
- captionClass = captionClass != null ? captionClass + " " + captionClass
: captionSkinClass;
+ captionClass = HtmlUtil.concatClasses(captionClass, captionSkinClass);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, captionClass,
"captionClass");
-
+
String captionStyle = (String)
dataTable.getAttributes().get("captionStyle");
-
if (captionStyle != null && captionStyle.trim().length() != 0) {
writer.writeAttribute(HTML.STYLE_ATTRIBUTE, captionStyle,
"captionStyle");
}
@@ -284,10 +267,8 @@
writer.endElement(HTML.CAPTION_ELEMENT);
}
- public EncodeStrategy getHeaderEncodeStrategy(UIComponent column, String
tableFacetName) {
-
- return (column instanceof org.richfaces.component.UIColumn &&
"header".equals(tableFacetName))
- ? new RichHeaderEncodeStrategy() : new SimpleHeaderEncodeStrategy();
+ public EncodeStrategy getHeaderEncodeStrategy(UIComponent column, String facetName)
{
+ return (column instanceof org.richfaces.component.UIColumn &&
UIDataTableBase.HEADER.equals(facetName)) ? new RichHeaderEncodeStrategy() : new
SimpleHeaderEncodeStrategy();
}
public boolean containsThead() {
@@ -303,17 +284,17 @@
}
public void encodeClientScript(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase) throws IOException {
-
UIDataTable dataTable = (UIDataTable) dataTableBase;
+
writer.startElement(HTML.SCRIPT_ELEM, dataTable);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.JAVASCRIPT_TYPE, null);
JSFunction function = new JSFunction("new RichFaces.ui.DataTable");
function.addParameter(dataTable.getClientId(facesContext));
- Map<String, Object> options = new HashMap<String, Object>();
-
AjaxEventOptions ajaxEventOptions =
AjaxRendererUtils.buildEventOptions(facesContext, dataTable);
+
+ Map<String, Object> options = new HashMap<String, Object>();
options.put("ajaxEventOptions", ajaxEventOptions.getParameters());
function.addParameter(options);
@@ -322,8 +303,7 @@
}
@Override
- public void encodeHiddenInput(ResponseWriter writer, FacesContext context,
UIDataTableBase component)
- throws IOException {
+ public void encodeHiddenInput(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException {
}
public String getTableSkinClass() {
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-24
14:10:07 UTC (rev 17667)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-24
14:18:53 UTC (rev 17668)
@@ -55,14 +55,15 @@
private static final String OPTIONS = ":options";
- private static final String HIDDEN_STYLE = "display: none";
+ private static final String DISPLAY_NONE = "display: none;";
private class SubTableHiddenEncodeStrategy implements EncodeStrategy {
+
public void begin(ResponseWriter writer, FacesContext context, UIComponent
component, Object[] params) throws IOException {
UISubTable subTable = (UISubTable)component;
writer.startElement(HTML.TR_ELEMENT, subTable);
writer.writeAttribute(HTML.ID_ATTRIBUTE, subTable.getClientId(context) +
HIDDEN_CONTAINER_ID, null);
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, HIDDEN_STYLE, null);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
writer.startElement(HTML.TD_ELEM, subTable);
}
@@ -77,16 +78,16 @@
}
}
}
+
};
protected void doDecode(FacesContext facesContext, UIComponent component) {
UISubTable subTable = (UISubTable)component;
-
+
String clientId = subTable.getClientId(facesContext);
-
- String stateId = clientId + STATE;
Map<String, String> requestMap =
facesContext.getExternalContext().getRequestParameterMap();
-
+
+ String stateId = clientId + STATE;
String state = (String)requestMap.get(stateId);
boolean isExpand = true;
@@ -138,15 +139,14 @@
@Override
public void encodeTableBodyStart(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase) throws IOException {
UISubTable subTable = (UISubTable)dataTableBase;
+
UIDataTableBase component = findParent(subTable);
if(component instanceof UIDataTable) {
-
writer.startElement(HTML.TBODY_ELEMENT, null);
writer.writeAttribute(HTML.ID_ATTRIBUTE,
component.getRelativeClientId(facesContext) + ":" + subTable.getId() + TB_ROW,
null);
-
- String predefinedStyles = !subTable.isExpanded() ? "display:
none;" : null;
-
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, getTableSkinClass(), null);
+
+ String predefinedStyles = !subTable.isExpanded() ? DISPLAY_NONE : null;
encodeStyle(writer, facesContext, subTable, predefinedStyles);
}
}
@@ -162,7 +162,7 @@
private void encodeSubTableDomElement(ResponseWriter writer, FacesContext
facesContext, UISubTable subTable) throws IOException{
writer.startElement(HTML.TR_ELEMENT, subTable);
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "display: none", null);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
writer.writeAttribute(HTML.ID_ATTRIBUTE, subTable.getClientId(facesContext),
null);
writer.startElement(HTML.TD_ELEM, subTable);
writer.endElement(HTML.TD_ELEM);
@@ -212,15 +212,11 @@
@Override
public boolean encodeParentTBody(UIDataTableBase dataTableBase) {
UIDataTableBase parent = findParent((UISubTable)dataTableBase);
- if(parent instanceof UIDataTable) {
- return true;
- }
- return false;
+ return (parent instanceof UIDataTable);
}
public void encodeHiddenInput(ResponseWriter writer, FacesContext facesContext,
UIDataTableBase dataTableBase)
throws IOException {
-
UISubTable subTable = (UISubTable) dataTableBase;
String stateId = subTable.getClientId(facesContext) + STATE;
@@ -229,7 +225,9 @@
writer.writeAttribute(HTML.ID_ATTRIBUTE, stateId, null);
writer.writeAttribute(HTML.NAME_ATTRIBUTE, stateId, null);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
- int state = subTable.isExpanded() ? 1 : 0;
+
+ int state = subTable.isExpanded() ? UISubTable.EXPAND_STATE :
UISubTable.COLLAPSE_STATE;
+
writer.writeAttribute(HTML.VALUE_ATTRIBUTE, state, null);
writer.endElement(HTML.INPUT_ELEM);
@@ -273,7 +271,7 @@
jsFunction.addParameter(options);
writer.startElement(HTML.SCRIPT_ELEM, subTable);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.JAVASCRIPT_TYPE, null);
writer.writeText(jsFunction.toScript(), null);
writer.endElement(HTML.SCRIPT_ELEM);
}
@@ -361,7 +359,6 @@
@Override
public void encodeMetaComponent(FacesContext facesContext, UIComponent component,
String metaComponentId)
throws IOException {
-
UISubTable subTable = (UISubTable)component;
setupTableStartElement(facesContext, subTable);
@@ -369,7 +366,7 @@
ResponseWriter writer = facesContext.getResponseWriter();
UIDataTableBase dataTableBase = findParent(subTable);
- String updateId = dataTableBase.getRelativeClientId(facesContext) +
":" + subTable.getId() +TB_ROW;
+ String updateId = dataTableBase.getRelativeClientId(facesContext) +
":" + subTable.getId() + TB_ROW;
partialStart(facesContext, updateId);
encodeTableRows(writer, facesContext, subTable, false);
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-06-24
14:10:07 UTC (rev 17667)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-06-24
14:18:53 UTC (rev 17668)
@@ -47,14 +47,14 @@
private static final String DISPLAY_NONE = "display: none;";
- private static final String EXPAND_STATE = "expand";
-
- private static final String COLLAPSE_STATE = "collapse";
-
private static final String UP_ICON_URL = "up_icon.gif";
private static final String DOWN_ICON_URL = "down_icon.gif";
+
+ private static final String EXPAND_STATE = "expand";
+ private static final String COLLAPSE_STATE = "collapse";
+
@Override
protected void doDecode(FacesContext context, UIComponent component) {
context.getPartialViewContext().getRenderIds().add(component.getClientId(context));
@@ -65,19 +65,17 @@
UISubTable subTable = findComponent(context, toggleControl);
if (subTable != null) {
- ResponseWriter writer = context.getResponseWriter();
-
- String toggleId = toggleControl.getClientId(context);
- Map<String, Object> options = encodeOptions(context, toggleControl,
subTable);
String switchType = subTable.getExpandMode();
-
boolean expanded = subTable.isExpanded();
-
+
+ ResponseWriter writer = context.getResponseWriter();
encodeControl(context, writer, toggleControl, switchType, expanded, false);
encodeControl(context, writer, toggleControl, switchType, !expanded, true);
JSFunction jsFunction = new JSFunction("new
RichFaces.ui.SubTableToggler");
+ String toggleId = toggleControl.getClientId(context);
jsFunction.addParameter(toggleId);
+ Map<String, Object> options = encodeOptions(context, toggleControl,
subTable);
jsFunction.addParameter(options);
writer.startElement(HTML.SCRIPT_ELEM, subTable);
@@ -108,9 +106,9 @@
if (controlFacet != null && controlFacet.isRendered()) {
if (!visible) {
- String facetStyle = (String)
controlFacet.getAttributes().get("style");
- facetStyle = facetStyle != null ? facetStyle + "; display:
none" : "; display: none";
- controlFacet.getAttributes().put("style", facetStyle);
+ String facetStyle = (String)
controlFacet.getAttributes().get(HTML.STYLE_ATTRIBUTE);
+ facetStyle = facetStyle != null ? facetStyle + ";" +
DISPLAY_NONE : DISPLAY_NONE;
+ controlFacet.getAttributes().put(HTML.STYLE_ATTRIBUTE, facetStyle);
}
controlFacet.encodeAll(context);
encodeDefault = false;
@@ -152,7 +150,6 @@
writer.writeAttribute(HTML.ALT_ATTRIBUTE, "", null);
writer.endElement(HTML.IMG_ELEMENT);
}
-
}
writer.endElement(HTML.SPAN_ELEM);
@@ -189,7 +186,6 @@
if (subTable instanceof UISubTable) {
return (UISubTable) subTable;
}
-
}
return null;
}