Author: abelevich
Date: 2009-10-29 06:59:41 -0400 (Thu, 29 Oct 2009)
New Revision: 15772
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncodeEvent.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeEvent.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncodeEvent.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncoder.java
Removed:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncoder.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/HeaderEncodeStrategy.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleCellEncoder.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleColgroupRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/colgroup.template.xml
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml
Log:
remove subtable, columnGroup renderers, add RowEncoder class which fires Row/Cell encode
events when row, cell encode occurs
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -22,7 +22,6 @@
import java.util.Iterator;
-import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
/**
@@ -30,7 +29,7 @@
* @author asmirnov
*
*/
-class ColumnsIterator extends IteratorBase<javax.faces.component.UIColumn> {
+class ColumnsIterator extends IteratorBase<UIComponent> {
protected Iterator<UIComponent> childrenIterator;
@@ -40,11 +39,11 @@
this.childrenIterator = dataTable.getChildren().iterator();
}
- protected javax.faces.component.UIColumn nextItem(){
+ protected UIComponent nextItem(){
while (childrenIterator != null && childrenIterator.hasNext()) {
UIComponent child = childrenIterator.next();
- if(child instanceof javax.faces.component.UIColumn){
- return (UIColumn)child;
+ if(child instanceof javax.faces.component.UIColumn || child instanceof Column){
+ return child;
}
}
return null;
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -37,6 +37,7 @@
}
protected UIComponent nextItem() {
+
UIComponent nextColumn = null;
while (nextColumn == null && childrenIterator.hasNext()) {
UIComponent child = childrenIterator.next();
@@ -47,6 +48,7 @@
}
}
+ // ???
while (nextColumn == null && facetsIterator.hasNext()) {
UIComponent component = facetsIterator.next();
if(checkAjaxComponent(component)){
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -23,7 +23,7 @@
import java.util.Iterator;
-import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
import javax.faces.component.UIPanel;
/**
@@ -36,7 +36,7 @@
public static final String COMPONENT_FAMILY = "org.richfaces.Colgroup";
- public Iterator<UIColumn> columns(){
+ public Iterator<UIComponent> columns(){
return new ColumnsIterator(this);
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -2,12 +2,11 @@
import java.util.Iterator;
-import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
-public class UIDataTable extends UISequence{
+public class UIDataTable extends UISequence {
- public Iterator<UIColumn> columns() {
+ public Iterator<UIComponent> columns() {
return new ColumnsIterator(this);
}
@@ -34,5 +33,8 @@
return getFacet("caption");
}
-
+ @Override
+ public boolean getRendersChildren() {
+ return true;
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISimpleDataTable.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -10,4 +10,5 @@
*/
public abstract class UISimpleDataTable extends UIDataTable {
+
}
\ No newline at end of file
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -24,6 +24,7 @@
import java.util.Iterator;
import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
/**
@@ -54,9 +55,19 @@
// SubTable is not sortable element.
return null;
}
-
+
+ @Override
+ public void resetDataModel(FacesContext context) {
+ super.resetDataModel(context);
+ }
+
public void setSortExpression(String sortExpression) {
// Do nothing - subtable is not sortable element;
}
+
+ @Override
+ public boolean getRendersChildren() {
+ return false;
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -24,7 +24,6 @@
import java.io.IOException;
import java.util.Map;
-import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -34,7 +33,6 @@
import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.Column;
import org.richfaces.component.UIDataAdaptor;
import org.richfaces.component.UIDataTable;
@@ -42,7 +40,7 @@
* @author shura
*
*/
-public abstract class AbstractRowsRenderer extends RendererBase implements DataVisitor {
+public abstract class AbstractRowsRenderer extends RendererBase implements DataVisitor,
ElementEncodeListener {
public static final String[][] TABLE_EVENT_ATTRS = {
{"onclick","onRowClick"},
@@ -63,17 +61,12 @@
public static final String SKIN_CELL_CLASS_KEY = AbstractRowsRenderer.class.getName() +
".skinCellClass";
public static final String SKIN_FIRST_ROW_CLASS_KEY =
AbstractRowsRenderer.class.getName() + ".firstRowSkinClass";
+
-
- public abstract void doProcess(FacesContext facesContext, TableHolder holder) throws
IOException;
-
- public abstract void encodeOneRow(FacesContext context, TableHolder holder) throws
IOException;
-
- public abstract void encodeCell(FacesContext context, UIComponent cell) throws
IOException;
-
protected abstract String getCellSkinClass();
-
+ public abstract RowEncoder getRowEncoder(TableHolder holder);
+
protected String getCellStyleClasses(FacesContext context, UIComponent component) {
StringBuffer styleClass = new StringBuffer();
// Construct predefined classes
@@ -98,13 +91,15 @@
}
- public DataVisitResult process(FacesContext facesContext, Object rowKey, Object
argument) {
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
TableHolder holder = (TableHolder) argument;
UIDataAdaptor table = holder.getTable();
- table.setRowKey(facesContext, rowKey);
+ table.setRowKey(context, rowKey);
try {
- doProcess(facesContext, holder);
- }catch (IOException e) {
+ RowEncoder encoder = getRowEncoder(holder);
+ encoder.setHeader(false);
+ encoder.encodeRows(context, table);
+ } catch (IOException e) {
//TODO: seems we need add throws IOException ???
}
holder.nextRow();
@@ -112,11 +107,11 @@
}
public void encodeRows(FacesContext facesContext, UIDataTable table) throws IOException
{
- encodeRows(facesContext, table, new TableHolder(table));
+ TableHolder tableHolder = new TableHolder(table);
+ encodeRows(facesContext, table, tableHolder);
}
- protected void encodeRows(FacesContext context, UIDataTable component, TableHolder
tableHolder) throws IOException {
- UIDataTable table = component;
+ protected void encodeRows(FacesContext context, UIDataTable table, TableHolder
tableHolder) throws IOException {
Object key = table.getRowKey();
table.captureOrigValue(context);
@@ -231,6 +226,7 @@
* @throws IOException
*/
+/*
protected void encodeCellChildren(FacesContext context, UIComponent cell,
String skinFirstRowClass, String skinRowClass, String rowClass,
String skinCellClass, String cellClass) throws IOException {
@@ -262,13 +258,9 @@
requestMap.put(SKIN_CELL_CLASS_KEY, skinCellClass);
}
-
- if((cell instanceof Column) && (cell instanceof UIColumn)) {
- encodeCell(context, cell);
- } else {
- renderChild(context, cell);
- }
+ encodeCell(context, cell);
+
// Restore original values.
requestMap.put(ROW_CLASS_KEY, savedRowClass);
requestMap.put(CELL_CLASS_KEY, savedCellClass);
@@ -277,6 +269,6 @@
requestMap.put(SKIN_CELL_CLASS_KEY, savedSkinCellClass);
}
+*/
-
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -21,13 +21,22 @@
})
public abstract class AbstractTableRenderer extends AbstractRowsRenderer {
- public abstract void encodeTBody (FacesContext context, UIDataTable table) throws
IOException;
+ public void encodeTableBody (FacesContext context, UIDataTable table) throws IOException
{
+ encodeBodyBegin(context, table);
+ encodeRows(context, table);
+ encodeBodyEnd(context, table);
+ }
+
+ public abstract void encodeBodyBegin(FacesContext context, UIDataTable table) throws
IOException;
+
+ public abstract void encodeBodyEnd(FacesContext context, UIDataTable table) throws
IOException;
+
public boolean isColumnFacetPresent(UIDataTable table, String facetName) {
- Iterator<UIColumn> columns = table.columns();
+ Iterator<UIComponent> columns = table.columns();
boolean result = false;
while(columns.hasNext() && !result) {
- UIColumn component = columns.next();
+ UIComponent component = columns.next();
result = (component.isRendered() && null != component.getFacet(facetName));
}
return result;
@@ -41,10 +50,10 @@
* @return true if specified attribute should generate header on the table
*/
public boolean isHeaderFactoryColumnAttributePresent(UIDataTable table,String
attributeName) {
- Iterator<UIColumn> columns = table.columns();
+ Iterator<UIComponent> columns = table.columns();
boolean result = false;
while (columns.hasNext() && !result) {
- UIColumn component = columns.next();
+ UIComponent component = columns.next();
result = (component.isRendered() && (null !=
component.getValueExpression(attributeName)));
}
return result;
@@ -65,7 +74,7 @@
return count;
}
- protected int calculateRowColumns(Iterator<UIColumn> col) {
+ protected int calculateRowColumns(Iterator<UIComponent> col) {
int count = 0;
int currentLength = 0;
while (col.hasNext()) {
@@ -114,7 +123,7 @@
@Override
public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
- encodeTBody(context, (UIDataTable) component);
+ encodeTableBody(context, (UIDataTable) component);
}
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncodeEvent.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncodeEvent.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncodeEvent.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -0,0 +1,35 @@
+package org.richfaces.renderkit;
+
+import java.util.Map;
+
+import javax.faces.component.UIColumn;
+import javax.faces.context.FacesContext;
+
+public class CellEncodeEvent implements ElementEncodeEvent <UIColumn> {
+
+ private FacesContext context;
+
+ private UIColumn source;
+
+ private Map<String, String> styleClasses;
+
+
+ public CellEncodeEvent(FacesContext context, UIColumn source) {
+ this.context = context;
+ this.source = source;
+ }
+
+ public FacesContext getContext() {
+ return this.context;
+ }
+
+ public UIColumn getSource() {
+ return this.source;
+ }
+
+ public Map<String, String> getStyleClasses() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Deleted:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncoder.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncoder.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/CellEncoder.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -1,28 +0,0 @@
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Anton Belevich
- *
- */
-public interface CellEncoder {
-
- public static String [] CELL_ATTRIBUTES = {
- "abbr" , "align" , "axis" , "bgcolor" ,
"char" , "charoff" , "colspan" , "dir" ,
- "headers" , "height" , "lang" , "nowrap" ,
"onclick" , "ondblclick" , "onkeydown" ,
- "onkeypress" , "onkeyup" , "onmousedown" ,
"onmousemove" , "onmouseout" , "onmouseover" ,
- "onmouseup" , "rowspan" , "scope" , "style"
, "title" , "valign" , "width" , "xml:lang" };
-
- public void encodeBegin(FacesContext context, UIComponent component) throws
IOException;
-
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException;
-
- public void setStyleClasses(String styleClasses);
-
- public String getStyleClasses();
-
-}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeEvent.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeEvent.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeEvent.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -0,0 +1,16 @@
+package org.richfaces.renderkit;
+
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+public interface ElementEncodeEvent <T extends UIComponent> {
+
+ public Map <String, String> getStyleClasses();
+
+ public T getSource();
+
+ public FacesContext getContext();
+
+}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -0,0 +1,25 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.UISubTable;
+
+public interface ElementEncodeListener {
+
+ public void encodeFirstCell(CellEncodeEvent event)throws IOException;
+
+ public void encodeHeaderCell(CellEncodeEvent event) throws IOException;
+
+ public void encodeCell(CellEncodeEvent event) throws IOException;
+
+ public void encodeFirstRow(RowEncodeEvent event) throws IOException;
+
+ public void encodeRowStart(RowEncodeEvent event) throws IOException;
+
+ public void encodeRowEnd(RowEncodeEvent event) throws IOException;
+
+ public void encodeSubTable(FacesContext context, UISubTable subTable) throws
IOException;
+
+}
Deleted:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/HeaderEncodeStrategy.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/HeaderEncodeStrategy.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/HeaderEncodeStrategy.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -1,38 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-public interface HeaderEncodeStrategy {
-
- public abstract void encodeBegin(FacesContext context, ResponseWriter writer,
- UIComponent column, String facetName, boolean sortableColumn) throws IOException;
-
- public abstract void encodeEnd(FacesContext context, ResponseWriter writer,
- UIComponent column, String facetName, boolean sortableColumn) throws IOException;
-
-}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncodeEvent.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncodeEvent.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncodeEvent.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -0,0 +1,34 @@
+package org.richfaces.renderkit;
+
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+public class RowEncodeEvent implements ElementEncodeEvent<UIComponent> {
+
+ private FacesContext context;
+
+ private UIComponent source;
+
+ private Map<String, String> styleClasses;
+
+ public RowEncodeEvent(FacesContext context, UIComponent source) {
+ this.context = context;
+ this.source = source;
+ }
+
+ public FacesContext getContext() {
+ return this.context;
+ }
+
+ public UIComponent getSource() {
+ return this.source;
+ }
+
+ public Map<String, String> getStyleClasses() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncoder.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncoder.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowEncoder.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -0,0 +1,126 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.richfaces.component.Column;
+import org.richfaces.component.Row;
+import org.richfaces.component.UISubTable;
+
+
+public class RowEncoder {
+
+
+ private ElementEncodeListener listener;
+
+ private Map <String, String> styleClasses = new HashMap<String, String>();
+
+ private boolean header = false;
+
+ public void encodeCell(FacesContext context, UIColumn column, int currentColumn) throws
IOException {
+ CellEncodeEvent event = new CellEncodeEvent(context, column);
+ listener.encodeCell(event);
+ }
+
+ public void encodeHeaderCell(FacesContext context, UIColumn column, int currentColumn)
throws IOException {
+ CellEncodeEvent event = new CellEncodeEvent(context, column);
+ listener.encodeHeaderCell(event);
+ }
+
+ public void encodeRowEnd(FacesContext context, UIComponent component) throws IOException
{
+ RowEncodeEvent event = new RowEncodeEvent(context, component);
+ listener.encodeRowEnd(event);
+ }
+
+ public void encodeRowStart(FacesContext context, UIComponent component) throws
IOException {
+ RowEncodeEvent event = new RowEncodeEvent(context, component);
+ listener.encodeRowStart(event);
+ }
+
+ public void encodeFirstRow(FacesContext context, UIComponent row) throws IOException {
+ RowEncodeEvent event = new RowEncodeEvent(context, row);
+ listener.encodeFirstRow(event);
+ }
+
+ public ElementEncodeListener getListener() {
+ return listener;
+ }
+
+ public void setListener(ElementEncodeListener listener) {
+ this.listener = listener;
+ }
+
+ public void encodeSubTable(FacesContext context, UISubTable subTable) throws IOException
{
+ subTable.resetDataModel(context);
+ listener.encodeSubTable(context, subTable);
+ }
+
+ public void encodeRows(FacesContext context, UIComponent component) throws IOException
{
+ boolean firstRow = true;
+ int currentColumn = 0;
+ Iterator<UIComponent> iterator = component.getChildren().iterator();
+ while(iterator.hasNext()) {
+
+ UIComponent child = iterator.next();
+ if(!(child instanceof UISubTable)) {
+
+ if(firstRow) {
+ encodeRowStart(context, child);
+ firstRow = false;
+ }
+
+ if(child instanceof Row) {
+ if(!firstRow) {
+ encodeRowEnd(context, null);
+ }
+ encodeRows(context, child);
+ }
+
+ if(child instanceof UIColumn) {
+
+ UIColumn column = (UIColumn)child;
+ //TODO: check
+ if(column instanceof Column && ((Column)column).isBreakBefore()) {
+ encodeRows(context, column);
+ }
+
+ if(header) {
+ encodeHeaderCell(context, column, currentColumn);
+ } else {
+ encodeCell(context, column, currentColumn);
+ }
+
+ }
+
+ } else {
+ UISubTable subTable = (UISubTable)child;
+ encodeSubTable(context,subTable);
+ }
+ }
+ encodeRowEnd(context, null);
+ }
+
+ public RendererUtils getRenderUtils() {
+ return RendererUtils.getInstance();
+ }
+
+ public void setStyleClass(String key, String value) {
+ styleClasses.put(key, value);
+ }
+
+ public boolean isHeader() {
+ return header;
+ }
+
+ public void setHeader(boolean header) {
+ this.header = header;
+ }
+
+}
Deleted:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleCellEncoder.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleCellEncoder.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleCellEncoder.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -1,65 +0,0 @@
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-
-/**
- * @author Anton Belevich
- *
- */
-public class SimpleCellEncoder implements CellEncoder {
-
- RendererUtils utils;
- String styleClasses;
-
-
- public SimpleCellEncoder(RendererUtils utils) {
- this(utils, null);
- }
-
- SimpleCellEncoder(RendererUtils utils, String styleClasses) {
- this.utils = utils;
- this.styleClasses = styleClasses;
- }
-
- public void encodeBegin(FacesContext context, UIComponent component) throws
IOException{
-
- ResponseWriter writer = context.getResponseWriter();
- String classes = getStyleClasses();
-
- String element = getElement();
- writer.startElement(element, component);
-
- String clientId = component.getClientId(context);
-
- utils.writeAttribute(writer, "class",classes);
- utils.writeAttribute(writer, "id", clientId );
- utils.encodeAttributesFromArray(context,component,CELL_ATTRIBUTES);
-
- }
-
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException{
- ResponseWriter writer = context.getResponseWriter();
- String element = getElement();
- writer.endElement(element);
- }
-
- protected String getElement() {
- boolean isHeader = styleClasses != null ? styleClasses.contains("header") :
false;
- return isHeader ? HTML.th_ELEM : HTML.td_ELEM;
- }
-
- public String getStyleClasses() {
- return styleClasses;
- }
-
- public void setStyleClasses(String styleClasses) {
- this.styleClasses = styleClasses;
- }
-}
Deleted:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleColgroupRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleColgroupRenderer.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleColgroupRenderer.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -1,189 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.UIColumn;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.Column;
-import org.richfaces.component.UIColumnGroup;
-
-/**
- * @author shura
- *
- */
-public class SimpleColgroupRenderer extends AbstractRowsRenderer {
-
- public static final String[] EVENT_ATTRS ;
-
- static {
- EVENT_ATTRS = new String[AbstractRowsRenderer.TABLE_EVENT_ATTRS.length];
- for (int i = 0; i < AbstractRowsRenderer.TABLE_EVENT_ATTRS.length; i++) {
- EVENT_ATTRS[i]=AbstractRowsRenderer.TABLE_EVENT_ATTRS[i][0];
- }
- }
-
-
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
colgroup) throws IOException {
- encodeRowStart(context, colgroup, writer, 0);
- }
-
- public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
- UIColumnGroup colgroup = (UIColumnGroup) component;
-
- String columnClasses = (String)
component.getAttributes().get("columnClasses");
- String[] classes = columnClasses != null ? columnClasses.split(",") : null;
-
- Iterator<UIColumn> iter = colgroup.columns();
-
- int currentColumn = 0;
- int currentRow = 0;
- boolean first = true;
-
- ResponseWriter writer = context.getResponseWriter();
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-
- while (iter.hasNext()) {
-
- UIColumn column = iter.next();
- if (column instanceof Column) {
-
- boolean breakBefore = ((Column) column).isBreakBefore();
- if (breakBefore && !first) {
- // close current row
- writer.endElement(HTML.TR_ELEMENT);
- // reset columns counter.
- currentColumn = 0;
- currentRow++;
- // Start new row, expect a case of the detail table, wich
- // will be insert own row.
- encodeRowStart(context, colgroup, writer, currentRow);
- }
-
- String styleClass = classes != null ? classes[currentColumn % classes.length] : null;
- encodeCellChildren(context, column, null, null, null,
- (String) requestMap.get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY),styleClass);
- } else {
- // UIColumn don't have own renderer
- if (column.isRendered()) {
- writer.startElement(HTML.td_ELEM, column);
- getUtils().encodeId(context, column);
- String styleClass = classes != null ? classes[currentColumn % classes.length] :
- (String) column.getAttributes().get("styleClass");
-
- encodeStyleClass(context.getResponseWriter(),
requestMap.get(AbstractRowsRenderer.SKIN_CELL_CLASS_KEY),
- "rich-table-cell",
requestMap.get(AbstractRowsRenderer.CELL_CLASS_KEY), styleClass);
- // TODO - encode column attributes.
- renderChildren(context, column);
- writer.endElement(HTML.td_ELEM);
-
- }
-
- }
-
- currentColumn++;
- first = false;
- }
- }
-
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- writer.endElement(HTML.TR_ELEMENT);
- }
-
- private void encodeRowStart(FacesContext context, UIComponent colspan, ResponseWriter
writer, int currentRow) throws IOException {
- writer.startElement(HTML.TR_ELEMENT, colspan);
-
- String styleClass;
- String rowClasses = (String) colspan.getAttributes().get("rowClasses");
- if (null != rowClasses) {
- String[] classes = rowClasses.split(",");
- styleClass = classes[currentRow % classes.length];
- } else {
- styleClass = (String) colspan.getAttributes().get("styleClass");
- }
-
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
- Object skinRowClass = currentRow == 0 ?
requestMap.get(AbstractRowsRenderer.SKIN_FIRST_ROW_CLASS_KEY):
- requestMap.get(AbstractRowsRenderer.SKIN_ROW_CLASS_KEY);
-
- encodeStyleClass(context.getResponseWriter(), skinRowClass, "rich-tablerow",
requestMap
- .get(AbstractRowsRenderer.ROW_CLASS_KEY), styleClass);
-
- String style = (String) colspan.getAttributes().get("style");
- encodeStyle(context.getResponseWriter(),null, null, null, style);
-
- getUtils().encodePassThruWithExclusionsArray(context, colspan,EVENT_ATTRS, null);
- // Search for enclosed DataAdaptor.
- UIComponent parent = colspan.getParent();
- // ENCODE event attributes. If component don't have own attribute, search in the
parent table.
- boolean inRow = null != parent && parent.getChildren().contains(colspan);
- for (int i = 0; i < AbstractRowsRenderer.TABLE_EVENT_ATTRS.length; i++) {
-
- String[] attrs = AbstractRowsRenderer.TABLE_EVENT_ATTRS[i];
- String event = (String) colspan.getAttributes().get(attrs[0]);
-
- if(null == event && inRow){
- event = (String) parent.getAttributes().get(attrs[1]);
- }
-
- if(null != event){
- writer.writeAttribute(attrs[0], event, attrs[0]);
- }
- }
- }
-
- public boolean getRendersChildren() {
- return true;
- }
-
- protected Class<? extends UIComponent> getComponentClass() {
- return UIColumnGroup.class;
- }
-
- public void encodeOneRow(FacesContext context, TableHolder holder) throws IOException {
- }
-
- @Override
- public void doProcess(FacesContext facesContext, TableHolder holder) throws IOException
{
- }
-
- @Override
- public void encodeCell(FacesContext context, UIComponent cell) throws IOException {
- CellEncoder cellEncode = new SimpleCellEncoder(getUtils(), getCellStyleClasses(context,
cell));
- cellEncode.encodeBegin(context, cell);
- renderChildren(context, cell);
- cellEncode.encodeEnd(context, cell);
- }
-
- @Override
- protected String getCellSkinClass() {
- //TODO: for test use.
- return "rich-table-cell";
- }
-}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SimpleDataTableRendererBase.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -11,9 +11,9 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.Column;
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTable;
+import org.richfaces.component.UISubTable;
@ResourceDependencies({
@ResourceDependency(name = "simple-datatable.js"),
@@ -21,17 +21,61 @@
})
public abstract class SimpleDataTableRendererBase extends AbstractTableRenderer {
+ public void encodeRowStart(RowEncodeEvent event) throws IOException {
+ ResponseWriter writer = event.getContext().getResponseWriter();
+ writer.startElement(HTML.TR_ELEMENT, event.getSource());
+ }
- @Override
- public void encodeCell(FacesContext context, UIComponent component) throws IOException
{
+ public void encodeRowEnd(RowEncodeEvent event) throws IOException {
+ ResponseWriter writer = event.getContext().getResponseWriter();
+ writer.endElement(HTML.TR_ELEMENT);
+ }
- CellEncoder cellEncode = new SimpleCellEncoder(getUtils(), getCellStyleClasses(context,
component));
- cellEncode.encodeBegin(context, component);
- renderChildren(context, component);
- cellEncode.encodeEnd(context, component);
+ public void encodeFirstRow(RowEncodeEvent event)throws IOException {
+ ResponseWriter writer = event.getContext().getResponseWriter();
+ writer.startElement(HTML.TR_ELEMENT, event.getSource());
+ }
+ public void encodeCell(CellEncodeEvent event) throws IOException {
+ ResponseWriter writer = event.getContext().getResponseWriter();
+ FacesContext context = event.getContext();
+ UIColumn column = event.getSource();
+
+ writer.startElement(HTML.td_ELEM, column);
+ getUtils().encodeId(context, column);
+ getCellStyleClasses(context, column);
+ renderChildren(context, column);
+
+ writer.endElement(HTML.td_ELEM);
}
+ public void encodeHeaderCell(CellEncodeEvent event) throws IOException {
+ ResponseWriter writer = event.getContext().getResponseWriter();
+ FacesContext context = event.getContext();
+ UIColumn column = event.getSource();
+
+ writer.startElement(HTML.th_ELEM, column);
+ //TODO --- move to the separate method
+ getUtils().encodeId(context, column);
+ getCellStyleClasses(context, column);
+ renderChildren(context, column);
+ //------
+ writer.endElement(HTML.th_ELEM);
+ }
+
+ @Override
+ public RowEncoder getRowEncoder(TableHolder holder) {
+ RowEncoder encoder = new RowEncoder();
+ encoder.setListener(this);
+ return encoder;
+ }
+
+ public void encodeSubTable(FacesContext context, UISubTable subTable) throws IOException
{
+ encodeRows(context, subTable);
+ }
+
+ //
---------------------------------------------------------------------------------------
+
public void encodeTableStructure(FacesContext context, UIDataTable table) throws
IOException{
Object key = table.getRowKey();
@@ -90,17 +134,18 @@
writer.endElement("caption");
}
-
+/*
@Override
- public void doProcess(FacesContext facesContext, TableHolder holder) throws IOException
{
- UIDataTable table = holder.getTable();
- ResponseWriter writer = facesContext.getResponseWriter();
-
- writer.startElement(HTML.TR_ELEMENT, table);
- encodeOneRow(facesContext, holder);
- writer.endElement(HTML.TR_ELEMENT);
+ public void encodeCell(FacesContext context, UIComponent component) throws IOException
{
+ CellEncoder cellEncode = new SimpleCellEncoder(getUtils(), getCellStyleClasses(context,
component));
+ cellEncode.encodeBegin(context, component);
+ renderChildren(context, component);
+ cellEncode.encodeEnd(context, component);
+
}
+ */
+
public void encodeHeader(FacesContext context, UIDataTable table, int columns) throws
IOException {
UIComponent header = table.getHeader();
boolean isEncodeHeaders = isEncodeHeaders(table);
@@ -133,7 +178,7 @@
public void encodeFooter(FacesContext context, UIDataTable table, int columns) throws
IOException {
ResponseWriter writer = context.getResponseWriter();
- Iterator<UIColumn> tableColumns = table.columns();
+ Iterator<UIComponent> tableColumns = table.columns();
UIComponent footer = table.getFooter();
boolean columnFacetPresent = isColumnFacetPresent(table,"footer");
@@ -176,16 +221,21 @@
writer.writeAttribute("scope", "colgroup", null);
}
- encodeCellChildren(context, footer, skinFirstRowClass, skinRowClass,
- footerClass, skinCellClass, null);
-
+ if(isColgroup) {
+ RowEncoder encoder = getRowEncoder(null);
+ encoder.setHeader(true);
+ encoder.encodeRows(context, footer);
+ } else {
+ renderChild(context, footer);
+ }
+
if (!isColgroup) {
writer.endElement(element);
writer.endElement("tr");
}
}
- protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer,
Iterator<UIColumn> headers,
+ protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer,
Iterator<UIComponent> headers,
String skinCellClass, String headerClass, String facetName, String element, int
colCount) throws IOException {
int t_colCount = 0;
@@ -195,7 +245,7 @@
// SimpleHeaderEncodeStrategy();
while (headers.hasNext()) {
- UIColumn column = (UIColumn) headers.next();
+ UIComponent column = headers.next();
if (!column.isRendered()) {
continue;
}
@@ -219,39 +269,29 @@
writer.writeAttribute("scope", "col", null);
getUtils().encodeAttribute(context, column, "colspan");
- // boolean sortableColumn = column.getValueExpression("comparator")
- // != null
- // || column.getValueExpression("sortBy") != null;
-
- // HeaderEncodeStrategy strategy = (column instanceof
- // org.richfaces.component.UIColumn
- // && "header".equals(facetName)) ? richEncodeStrategy :
- // simpleEncodeStrategy;
- //
- // strategy.encodeBegin(context, writer, column, facetName,
- // sortableColumn);
-
UIComponent facet = column.getFacet(facetName);
if (facet != null && facet.isRendered()) {
renderChild(context, facet);
}
- // strategy.encodeEnd(context, writer, column, facetName,
- // sortableColumn);
-
writer.endElement(element);
}
}
- public void encodeTBody (FacesContext context, UIDataTable table) throws IOException {
+ @Override
+ public void encodeBodyBegin(FacesContext context, UIDataTable table) throws IOException
{
String clientId = table.getClientId(context);
ResponseWriter writer = context.getResponseWriter();
writer.startElement("tbody", table);
writer.writeAttribute("id", clientId + ":tb", null);
- encodeRows(context, table);
- writer.endElement("tbody");
}
+ @Override
+ public void encodeBodyEnd(FacesContext context, UIDataTable table) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.endElement("tbody");
+ }
+
protected String getRowSkinClasses(boolean firstColumn) {
String rowSkinClass = getRowSkinClass();
if (firstColumn) {
@@ -264,105 +304,7 @@
return rowSkinClass;
}
-
- @Override
- public void encodeOneRow(FacesContext context, TableHolder holder) throws IOException {
-
- boolean firstColumn = true;
- boolean firstRow = (holder.getRowCounter() == 0);
- int currentColumn = 0;
- UIComponent column = null;
-
- ResponseWriter writer = context.getResponseWriter();
-
- UIDataTable table = (UIDataTable) holder.getTable();
- Iterator<UIColumn> iter = table.columns();
-
- while (iter.hasNext()) {
- column = iter.next();
- boolean isRow = (column instanceof Row);
-
- // Start new row for first column - expect a case of the detail
- // table, wich will be insert own row.
- if (firstColumn && (!isRow)) {
- String rowSkinClass = getRowSkinClasses(true);
- encodeRowStart(context, rowSkinClass, holder.getRowClass(), table, writer);
- }
-
- if (column instanceof Column) {
- currentColumn = encodeRichColumn(context, writer, holder, column, currentColumn,
firstColumn, firstRow, isRow, iter.hasNext());
-
- } else if (column.isRendered()) {
- currentColumn = encodeColumn(context, writer, column, currentColumn, holder);
- }
-
- currentColumn++;
- firstColumn = false;
- }
-
- // Close row if then is open.
- if (!firstColumn && !(column instanceof Row)) {
- writer.endElement(HTML.TR_ELEMENT);
- }
-
- }
- protected int encodeRichColumn(FacesContext context, ResponseWriter writer,
- TableHolder holder, UIComponent column, int currentColumn,
- boolean firstColumn, boolean firstRow, boolean isRow,
- boolean hasNext) throws IOException {
-
- UIDataTable table = holder.getTable();
- boolean breakBefore = ((Column) column).isBreakBefore() || isRow;
-
- if (breakBefore && !firstColumn) {
- // close current row
- writer.endElement(HTML.TR_ELEMENT);
- // reset columns counter.
- currentColumn = 0;
- // Start new row, expect a case of the detail table, wich
- // will be insert own row.
- if (!isRow) {
- holder.nextRow();
- encodeRowStart(context, getRowSkinClass(),
- holder.getRowClass(), table, writer);
- }
- }
-
- String firstRowSkinClass = firstRow ? getFirstRowSkinClass() : null;
-
- encodeCellChildren(context, column, firstRowSkinClass,
- getRowSkinClass(), holder.getRowClass(), getCellSkinClass(),
- holder.getColumnClass(currentColumn));
- // renderChild(context, column);
- if (isRow && hasNext) {
- // Start new row for remained columns.
- holder.nextRow();
- encodeRowStart(context, getRowSkinClass(), holder.getRowClass(),
- table, writer);
- // reset columns counter.
- currentColumn = -1;
- }
-
- return currentColumn;
- }
-
- protected int encodeColumn(FacesContext context, ResponseWriter writer,
- UIComponent column, int currentColumn, TableHolder holder)
- throws IOException {
- // UIColumn don't have own renderer
- UIDataTable table = holder.getTable();
- writer.startElement(HTML.td_ELEM, table);
- getUtils().encodeId(context, column);
- String columnClass = holder.getColumnClass(currentColumn);
- encodeStyleClass(writer, null, getCellSkinClass(), null, columnClass);
-
- // TODO - encode column attributes.
- renderChildren(context, column);
- writer.endElement(HTML.td_ELEM);
-
- return currentColumn;
- }
/**
* @return
*/
@@ -383,43 +325,5 @@
protected String getCellSkinClass() {
return "rich-table-cell";
}
-
- protected void encodeRowStart(FacesContext context, String skinClass, String rowClass,
UIDataTable table, ResponseWriter writer) throws IOException {
- writer.startElement(HTML.TR_ELEMENT, table);
- encodeStyleClass(writer, null, skinClass, null, rowClass);
- encodeRowEvents(context, table);
- }
-/*
- protected class SimpleHeaderEncodeStrategy implements HeaderEncodeStrategy {
-
- public void encodeBegin(FacesContext context, ResponseWriter writer,
- UIComponent column, String facetName, boolean sortableColumn)
- throws IOException {
-
- }
-
- public void encodeEnd(FacesContext context, ResponseWriter writer,
- UIComponent column, String facetName, boolean sortableColumn)
- throws IOException {
-
- }
- }
-
- // will be changed
- protected class RichHeaderEncodeStrategy implements HeaderEncodeStrategy {
-
- public void encodeBegin(FacesContext context, ResponseWriter writer,
- UIComponent column, String facetName, boolean sortableColumn)
- throws IOException {
-
- }
-
- public void encodeEnd(FacesContext context, ResponseWriter writer,
- UIComponent column, String facetName, boolean sortableColumn)
- throws IOException {
-
- }
- }
-*/
}
Deleted:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -1,110 +0,0 @@
-/**
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import javax.faces.component.UIColumn;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.UIDataTable;
-import org.richfaces.component.UISubTable;
-
-/**
- * @author shura
- *
- */
-public class SubTableRenderer extends AbstractTableRenderer {
-
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- encodeHeaderRow(writer, context, component,"header");
- }
-
- /**
- * Encode one row with header/footer facets from columns.
- */
- private void encodeHeaderRow(ResponseWriter writer, FacesContext context, UIComponent
component,String facetName) throws IOException {
- UIDataTable dataTable = (UIDataTable) component;
- int colCount = getColumnsCount(dataTable);
- String headerClass = (String)
component.getAttributes().get(facetName+"Class");
-
- if (isColumnFacetPresent(dataTable, facetName)) {
- writer.startElement(HTML.TR_ELEMENT, dataTable);
- encodeStyleClass(writer, null, "rich-subtable-"+facetName, null,
headerClass);
- Iterator<UIColumn> columns = dataTable.columns();
- encodeHeaderFacets(context, writer, columns,
"rich-subtable-"+facetName+"cell", headerClass, facetName,
"td",colCount);
- writer.endElement(HTML.TR_ELEMENT);
- }
- }
-
- protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer,
Iterator<UIColumn> headers,
- String skinCellClass, String headerClass, String facetName, String element, int
colCount) throws IOException {
- //stub for test only!!
- }
-
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- encodeHeaderRow(writer, context, component,"footer");
- }
-
- protected String getRowSkinClass() {
- return "rich-subtable-row";
- }
-
- protected String getFirstRowSkinClass() {
- return "rich-subtable-firstrow";
- }
-
- protected String getCellSkinClass() {
- return "rich-subtable-cell";
- }
-
- protected Class<? extends UIComponent> getComponentClass() {
- return UISubTable.class;
- }
-
- @Override
- public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
- encodeRows(context, (UIDataTable) component);
- }
-
- @Override
- public void encodeTBody(FacesContext context, UIDataTable table) throws IOException {
- }
-
- @Override
- public void doProcess(FacesContext facesContext, TableHolder holder) throws IOException
{
- System.out.println("SubTableRenderer.doProcess()");
- }
-
- @Override
- public void encodeCell(FacesContext context, UIComponent cell) throws IOException {
- System.out.println("SubTableRenderer.encodeCell()");
- }
-
- @Override
- public void encodeOneRow(FacesContext context, TableHolder holder) throws IOException {
- System.out.println("SubTableRenderer.encodeOneRow()");
- }
-}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TableHolder.java 2009-10-29
10:59:41 UTC (rev 15772)
@@ -23,7 +23,7 @@
import java.util.Map;
-import org.richfaces.component.UIDataTable;
+import org.richfaces.component.UIDataAdaptor;
/**
* Private class for keep reference to table and intermediate iteration values ( current
row styles, events etc )
@@ -31,7 +31,7 @@
*
*/
public class TableHolder {
- private UIDataTable table;
+ private UIDataAdaptor component;
private int rowCounter;
private int gridRowCounter;
private String[] rowClasses;
@@ -40,11 +40,11 @@
/**
* @param table
*/
- public TableHolder(UIDataTable table) {
- this.table = table;
+ public TableHolder(UIDataAdaptor component) {
+ this.component = component;
this.rowCounter = 0;
this.gridRowCounter = 0;
- Map<String, Object> attributes = table.getAttributes();
+ Map<String, Object> attributes = component.getAttributes();
String classes = (String) attributes.get("rowClasses");
if(null != classes){
rowClasses=classes.split(",");
@@ -58,8 +58,8 @@
/**
* @return the table
*/
- public UIDataTable getTable() {
- return this.table;
+ public UIDataAdaptor getTable() {
+ return this.component;
}
/**
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/faces-config.xml 2009-10-29
10:59:41 UTC (rev 15772)
@@ -37,11 +37,16 @@
<renderer-type>org.richfaces.ExtendedDataTableRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.ExtendedDataTableRenderer</renderer-class>
</renderer>
- <renderer>
+ <!-- renderer>
<component-family>org.richfaces.Colgroup</component-family>
<renderer-type>org.richfaces.ColumnGroupRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.ColgroupRenderer</renderer-class>
</renderer>
+ <renderer>
+ <component-family>org.richfaces.SubTable</component-family>
+ <renderer-type>org.richfaces.renderkit.SubTableRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.SubTableRenderer</renderer-class>
+ </renderer -->
</render-kit>
</faces-config>
\ No newline at end of file
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/tables.taglib.xml 2009-10-29
10:59:41 UTC (rev 15772)
@@ -27,14 +27,14 @@
<tag-name>colGroup</tag-name>
<component>
<component-type>org.richfaces.Colgroup</component-type>
- <renderer-type>org.richfaces.ColumnGroupRenderer</renderer-type>
+ <!-- renderer-type>org.richfaces.ColumnGroupRenderer</renderer-type -->
</component>
</tag>
<tag>
<tag-name>subTable</tag-name>
<component>
<component-type>org.richfaces.SubTable</component-type>
- <renderer-type>org.richfaces.renderkit.SubTableRenderer</renderer-type>
+ <!--
renderer-type>org.richfaces.renderkit.SubTableRenderer</renderer-type-->
</component>
</tag>
</facelet-taglib>
Deleted:
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/colgroup.template.xml
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/colgroup.template.xml 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/colgroup.template.xml 2009-10-29
10:59:41 UTC (rev 15772)
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<cdk:root
xmlns="http://richfaces.org/xhtml-el"
xmlns:cdk="http://richfaces.org/cdk"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- class="org.richfaces.renderkit.html.ColgroupRenderer"
- superclass="org.richfaces.renderkit.SimpleColgroupRenderer"
- componentclass="org.richfaces.component.UIColumnGroup" >
- <tr id="#{clientId}">
- <cdk:body>
- <cdk:call expression="super.encodeChildren(context,component);"/>
- </cdk:body>
- </tr>
-</cdk:root>
\ No newline at end of file
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml 2009-10-29
06:18:21 UTC (rev 15771)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/simpletable.template.xml 2009-10-29
10:59:41 UTC (rev 15772)
@@ -8,7 +8,7 @@
<table id="#{clientId}">
<cdk:call expression="encodeTableStructure(context,component);" />
<cdk:body>
- <cdk:call expression="encodeTBody(context,component);" />
+ <cdk:call expression="encodeTableBody(context,component);" />
</cdk:body>
</table>
</cdk:root>
\ No newline at end of file