Author: Alex.Kolonitsky
Date: 2009-02-19 12:34:20 -0500 (Thu, 19 Feb 2009)
New Revision: 12694
Added:
trunk/samples/dataTableDemo/src/main/webapp/pages/page_RF-6152.jsp
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
trunk/samples/dataTableDemo/src/main/java/org/richfaces/Bean.java
trunk/samples/dataTableDemo/src/main/java/org/richfaces/Data.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java
trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumn.java
trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumnGroup.java
trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
Log:
DataTable: extra column header for breakBefore columns
https://jira.jboss.org/jira/browse/RF-6152
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2009-02-19
17:08:56 UTC (rev 12693)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2009-02-19
17:34:20 UTC (rev 12694)
@@ -977,14 +977,12 @@
}
// continue hack
- Iterator<UIComponent> itr = c.getChildren().iterator();
- while (itr.hasNext()) {
- restoreChildState(faces, (UIComponent) itr.next(), childState);
- }
- itr = c.getFacets().values().iterator();
- while (itr.hasNext()) {
- restoreChildState(faces, (UIComponent) itr.next(), childState);
- }
+ for (UIComponent child : c.getChildren()) {
+ restoreChildState(faces, child, childState);
+ }
+ for (UIComponent facet : c.getFacets().values()) {
+ restoreChildState(faces, facet, childState);
+ }
}
/**
@@ -998,21 +996,6 @@
// For an any validation errors, children components state should be preserved
FacesMessage.Severity sev = context.getMaximumSeverity();
return (sev != null && (FacesMessage.SEVERITY_ERROR.compareTo(sev) >= 0));
-
-
-// Iterator<String> clientIds = this.getChildState(context).keySet().iterator();
-// while (clientIds.hasNext()) {
-// String clientId = clientIds.next();
-// Iterator<FacesMessage> messages = context.getMessages(clientId);
-// while (messages.hasNext()) {
-// FacesMessage message = messages.next();
-// if (message.getSeverity()
-// .compareTo(FacesMessage.SEVERITY_ERROR) >= 0) {
-// return (true);
-// }
-// }
-// }
-// return false;
}
/**
@@ -1056,8 +1039,7 @@
* @return segment containing row key or <code>null</code>
*/
protected String extractKeySegment(FacesContext context, String tailId) {
- int indexOfSecondColon = tailId.indexOf(
- NamingContainer.SEPARATOR_CHAR);
+ int indexOfSecondColon = tailId.indexOf(NamingContainer.SEPARATOR_CHAR);
return (indexOfSecondColon > 0 ? tailId.substring(0, indexOfSecondColon) : null);
}
@@ -1103,7 +1085,7 @@
}
}
} else {
- String baseId = baseClientId+NamingContainer.SEPARATOR_CHAR;
+ String baseId = baseClientId + NamingContainer.SEPARATOR_CHAR;
if (clientId.startsWith(baseId)) {
Object newRowKey = null;
// Call for a child component - try to detect row key
@@ -1135,8 +1117,8 @@
}
}
}
- //
- return found;
+
+ return found;
}
/**
@@ -1356,15 +1338,13 @@
// Send event directly to parent, to avoid wrapping in superclass.
UIComponent parent = getParent();
if (parent == null) {
- throw new IllegalStateException(
- "No parent component for queue event");
+ throw new IllegalStateException("No parent component for queue event");
} else {
parent.queueEvent(event);
}
}
public void broadcast(FacesEvent event) throws AbortProcessingException {
-
if (!(event instanceof IndexedEvent)) {
if (!broadcastLocal(event)) {
super.broadcast(event);
@@ -1380,11 +1360,11 @@
Object eventRowKey = revent.getKey();
setRowKey(faces, eventRowKey);
FacesEvent rowEvent = revent.getTarget();
+
rowEvent.getComponent().broadcast(rowEvent);
+
setRowKey(faces, oldRowKey);
restoreOrigValue(faces);
- // }
- return;
}
/**
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java 2009-02-19
17:08:56 UTC (rev 12693)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java 2009-02-19
17:34:20 UTC (rev 12694)
@@ -25,12 +25,9 @@
import java.util.LinkedHashSet;
import javax.faces.component.UIComponent;
-import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.webapp.BaseFilter;
/**
* Base renderer for components used JavaScripts and Styles in header. In real
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2009-02-19
17:08:56 UTC (rev 12693)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2009-02-19
17:34:20 UTC (rev 12694)
@@ -22,7 +22,6 @@
package org.ajax4jsf.renderkit;
import java.io.IOException;
-import java.util.Iterator;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
@@ -254,14 +253,10 @@
* @param component
* @throws IOException
*/
- public void renderChildren(FacesContext facesContext,
- UIComponent component) throws IOException {
- if (component.getChildCount() > 0) {
- for (Iterator<UIComponent> it = component.getChildren().iterator();
it.hasNext();) {
- UIComponent child = it.next();
- renderChild(facesContext, child);
- }
- }
+ public void renderChildren(FacesContext facesContext, UIComponent component) throws
IOException {
+ for (UIComponent child : component.getChildren()) {
+ renderChild(facesContext, child);
+ }
}
Modified: trunk/samples/dataTableDemo/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/samples/dataTableDemo/src/main/java/org/richfaces/Bean.java 2009-02-19 17:08:56
UTC (rev 12693)
+++ trunk/samples/dataTableDemo/src/main/java/org/richfaces/Bean.java 2009-02-19 17:34:20
UTC (rev 12694)
@@ -31,7 +31,7 @@
*
*/
public class Bean {
- private List detail = new ArrayList();
+ private List<ChildBean> detail = new ArrayList<ChildBean>();
private String mounth;
@@ -50,14 +50,14 @@
/**
* @return the detail
*/
- public List getDetail() {
+ public List<ChildBean> getDetail() {
return this.detail;
}
/**
* @param detail the detail to set
*/
- public void setDetail(List detail) {
+ public void setDetail(List<ChildBean> detail) {
this.detail = detail;
}
Modified: trunk/samples/dataTableDemo/src/main/java/org/richfaces/Data.java
===================================================================
--- trunk/samples/dataTableDemo/src/main/java/org/richfaces/Data.java 2009-02-19 17:08:56
UTC (rev 12693)
+++ trunk/samples/dataTableDemo/src/main/java/org/richfaces/Data.java 2009-02-19 17:34:20
UTC (rev 12694)
@@ -21,10 +21,7 @@
package org.richfaces;
-import java.text.DateFormat;
import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
@@ -33,9 +30,9 @@
private static final String[]
mnames={"Jan","Feb","Mar","Apr","May"};
- private List mounths = new ArrayList();
+ private List<Bean> mounths = new ArrayList<Bean>();
- private List numbers = new ArrayList();
+ private List<Integer> numbers = new ArrayList<Integer>();
private boolean c3rendered=true;
@@ -62,20 +59,20 @@
/**
* @return the numbers
*/
- public List getNumbers() {
+ public List<Integer> getNumbers() {
return this.numbers;
}
/**
* @param numbers the numbers to set
*/
- public void setNumbers(List numbers) {
+ public void setNumbers(List<Integer> numbers) {
this.numbers = numbers;
}
public Data() {
Properties properties = System.getProperties();
- Enumeration keys = properties.keys();
+ Enumeration<?> keys = properties.keys();
for(int i=0;i<5;i++){
Bean bean = new Bean();
int l = (int)(Math.random()*5)+1;
@@ -99,14 +96,14 @@
/**
* @return the mounths
*/
- public List getMounths() {
+ public List<Bean> getMounths() {
return this.mounths;
}
/**
* @param mounths the mounths to set
*/
- public void setMounths(List mounths) {
+ public void setMounths(List<Bean> mounths) {
this.mounths = mounths;
}
Added: trunk/samples/dataTableDemo/src/main/webapp/pages/page_RF-6152.jsp
===================================================================
--- trunk/samples/dataTableDemo/src/main/webapp/pages/page_RF-6152.jsp
(rev 0)
+++ trunk/samples/dataTableDemo/src/main/webapp/pages/page_RF-6152.jsp 2009-02-19 17:34:20
UTC (rev 12694)
@@ -0,0 +1,34 @@
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://richfaces.org/a4j" prefix="a4j" %>
+<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/dataTable"
prefix="data" %>
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view >
+ <a4j:form>
+ <data:dataTable value="#{data.mounths}">
+ <data:column id="row1">
+ <f:facet name="header">
+ <h:outputText value="A"/>
+ </f:facet>
+ <h:outputText value="1"></h:outputText>
+ </data:column>
+ <data:column id="row3">
+ <f:facet name="header">
+ <h:outputText value="B"/>
+ </f:facet>
+ <h:outputText value="2"></h:outputText>
+ </data:column>
+ <data:columnGroup>
+ <data:column id="row2" colspan="2">
+ <h:outputText
value="3"></h:outputText>
+ </data:column>
+ </data:columnGroup>
+ </data:dataTable>
+ </a4j:form>
+ </f:view>
+ </body>
+</html>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java 2009-02-19
17:08:56 UTC (rev 12693)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java 2009-02-19
17:34:20 UTC (rev 12694)
@@ -77,6 +77,8 @@
}
+ private static final String CTRL_FORM = "_controls";
+
@Test
public void testSortingFeature(Template template) {
renderPage(SORTING_TEST_URL, template, RESET_METHOD);
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumn.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumn.java 2009-02-19
17:08:56 UTC (rev 12693)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumn.java 2009-02-19
17:34:20 UTC (rev 12694)
@@ -27,7 +27,6 @@
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.AjaxSupport;
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumnGroup.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumnGroup.java 2009-02-19
17:08:56 UTC (rev 12693)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/component/UIColumnGroup.java 2009-02-19
17:34:20 UTC (rev 12694)
@@ -36,7 +36,6 @@
public static final String COMPONENT_FAMILY = "org.richfaces.Colgroup";
- @SuppressWarnings("unchecked")
public Iterator<UIComponent> columns(){
return new ColumnsIterator(this);
}
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java 2009-02-19
17:08:56 UTC (rev 12693)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java 2009-02-19
17:34:20 UTC (rev 12694)
@@ -61,9 +61,7 @@
*
* @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#dataChildren()
*/
- @SuppressWarnings("unchecked")
public Iterator<UIComponent> dataChildren() {
-
return new DataIterator(this);
}
@@ -72,13 +70,10 @@
*
* @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#fixedChildren()
*/
- @SuppressWarnings("unchecked")
public Iterator<UIComponent> fixedChildren() {
-
return new FixedChildrenIterator(this);
}
- @SuppressWarnings("unchecked")
public Iterator<UIComponent> columns() {
return new ColumnsIterator(this);
}
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
---
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-02-19
17:08:56 UTC (rev 12693)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-02-19
17:34:20 UTC (rev 12694)
@@ -40,8 +40,8 @@
* @author shura
*
*/
-public abstract class AbstractRowsRenderer extends HeaderResourcesRendererBase
implements
- DataVisitor {
+public abstract class AbstractRowsRenderer extends HeaderResourcesRendererBase
+ implements DataVisitor {
public static final String[][] TABLE_EVENT_ATTRS = {
{"onclick","onRowClick"},
@@ -54,23 +54,20 @@
};
- public static final String ROW_CLASS_KEY = AbstractRowsRenderer.class
- .getName()
- + ".rowClass";
+ public static final String ROW_CLASS_KEY =
+ AbstractRowsRenderer.class.getName() + ".rowClass";
- public static final String SKIN_ROW_CLASS_KEY = AbstractRowsRenderer.class
- .getName()
- + ".skinRowClass";
+ public static final String SKIN_ROW_CLASS_KEY =
+ AbstractRowsRenderer.class.getName() + ".skinRowClass";
- public static final String CELL_CLASS_KEY = AbstractRowsRenderer.class
- .getName()
- + ".cellClass";
+ public static final String CELL_CLASS_KEY =
+ AbstractRowsRenderer.class.getName() + ".cellClass";
- public static final String SKIN_CELL_CLASS_KEY = AbstractRowsRenderer.class
- .getName()
- + ".skinCellClass";
+ 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 static final String SKIN_FIRST_ROW_CLASS_KEY =
+ AbstractRowsRenderer.class.getName() + ".firstRowSkinClass";
/*
* (non-Javadoc)
@@ -103,7 +100,9 @@
UIDataAdaptor table = (UIDataAdaptor) component;
Object key = table.getRowKey();
table.captureOrigValue(context);
+
table.walk(context, this, tableHolder);
+
doCleanup(context, tableHolder);
table.setRowKey(key);
table.restoreOrigValue(context);
@@ -140,28 +139,30 @@
public void encodeCaption(FacesContext context, SequenceDataAdaptor table)
throws IOException {
- ResponseWriter writer = context.getResponseWriter();
UIComponent caption = table.getFacet("caption");
- if (caption != null) {
- String captionClass = (String) table.getAttributes().get(
- "captionClass");
- String captionStyle = (String) table.getAttributes().get(
- "captionStyle");
- writer.startElement("caption", table);
- if (captionClass != null) {
- captionClass = "dr-table-caption rich-table-caption "
- + captionClass;
- } else {
- captionClass = "dr-table-caption rich-table-caption";
- }
- writer.writeAttribute("class", captionClass, "captionClass");
- if (captionStyle != null) {
- writer.writeAttribute("style", captionStyle, "captionStyle");
- }
- renderChild(context, caption);
- writer.endElement("caption");
+ if (caption == null) {
+ return;
}
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement("caption", table);
+
+ String captionClass = (String) table.getAttributes().get("captionClass");
+ if (captionClass != null) {
+ captionClass = "dr-table-caption rich-table-caption " + captionClass;
+ } else {
+ captionClass = "dr-table-caption rich-table-caption";
+ }
+ writer.writeAttribute("class", captionClass, "captionClass");
+
+ String captionStyle = (String)
table.getAttributes().get("captionStyle");
+ if (captionStyle != null) {
+ writer.writeAttribute("style", captionStyle, "captionStyle");
+ }
+
+ renderChild(context, caption);
+
+ writer.endElement("caption");
}
/**
@@ -210,8 +211,7 @@
styleClass.append(custom);
}
if (styleClass.length() > 0) {
- writer.writeAttribute(HTML.class_ATTRIBUTE, styleClass,
- "styleClass");
+ writer.writeAttribute(HTML.class_ATTRIBUTE, styleClass, "styleClass");
}
}
protected void encodeStyle(ResponseWriter writer, Object parentPredefined,
@@ -231,8 +231,7 @@
style.append(custom);
}
if (style.length() > 0) {
- writer.writeAttribute("style", style,
- "style");
+ writer.writeAttribute("style", style, "style");
}
}
@@ -255,7 +254,8 @@
protected void encodeCellChildren(FacesContext context, UIComponent cell,
String skinFirstRowClass, String skinRowClass, String rowClass,
String skinCellClass, String cellClass) throws IOException {
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+
+ Map<String, Object> requestMap =
context.getExternalContext().getRequestMap();
// Save top level class parameters ( if any ), and put new for this
// component
Object savedRowClass = requestMap.get(ROW_CLASS_KEY);
@@ -282,7 +282,9 @@
requestMap.put(SKIN_CELL_CLASS_KEY, skinCellClass);
}
+
renderChild(context, cell);
+
// Restore original values.
requestMap.put(ROW_CLASS_KEY, savedRowClass);
requestMap.put(CELL_CLASS_KEY, savedCellClass);
@@ -299,12 +301,15 @@
encodeStyleClass(writer, null, skinFirstRowClass, footerClass, null);
writer.startElement(element, footer);
encodeStyleClass(writer, null, skinCellClass, footerClass, null);
- if (columns>0) {
+ if (columns > 0) {
writer.writeAttribute("colspan", String.valueOf(columns), null);
}
writer.writeAttribute("scope", "colgroup", null);
}
- encodeCellChildren(context, footer,skinFirstRowClass,skinRowClass, footerClass,
skinCellClass, null);
+
+ encodeCellChildren(context, footer, skinFirstRowClass, skinRowClass,
+ footerClass, skinCellClass, null);
+
if (!isColgroup) {
writer.endElement(element);
writer.endElement("tr");
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-02-19
17:08:56 UTC (rev 12693)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-02-19
17:34:20 UTC (rev 12694)
@@ -129,20 +129,21 @@
*/
public void encodeTableStructure(FacesContext context, UIDataTable table)
throws IOException {
- ResponseWriter writer = context.getResponseWriter();
+
Object key = table.getRowKey();
table.captureOrigValue(context);
table.setRowKey(context, null);
+
encodeCaption(context, table);
- int columns = getColumnsCount(table);
+
// Encode colgroup definition.
+ ResponseWriter writer = context.getResponseWriter();
writer.startElement("colgroup", table);
+ int columns = getColumnsCount(table);
writer.writeAttribute("span", String.valueOf(columns), null);
String columnsWidth = (String) table.getAttributes().get("columnsWidth");
-
if (null != columnsWidth) {
-
String[] widths = columnsWidth.split(",");
for (int i = 0; i < widths.length; i++) {
writer.startElement("col", table);
@@ -151,26 +152,26 @@
}
}
writer.endElement("colgroup");
+
encodeHeader(context, table, columns);
encodeFooter(context, table, columns);
+
table.setRowKey(context,key);
table.restoreOrigValue(context);
}
public void encodeHeader(FacesContext context, UIDataTable table,
int numberOfColumns) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
+
UIComponent header = table.getHeader();
boolean columnFacetPresent = isColumnFacetPresent(table, "header");
boolean isFilterByPresent = isHeaderFactoryColumnAttributePresent(table,
"filterBy");
- Iterator<UIComponent> colums = table.columns();
-
-
if (header != null || columnFacetPresent || isFilterByPresent) {
+
+ ResponseWriter writer = context.getResponseWriter();
writer.startElement("thead", table);
writer.writeAttribute(HTML.class_ATTRIBUTE, "dr-table-thead", null);
- String headerClass = (String) table.getAttributes().get(
- "headerClass");
+ String headerClass = (String) table.getAttributes().get("headerClass");
if (header != null) {
encodeTableHeaderFacet(context, numberOfColumns, writer, header,
"dr-table-header rich-table-header",
@@ -184,7 +185,8 @@
encodeStyleClass(writer, null,
"dr-table-subheader rich-table-subheader", null,
headerClass);
- encodeHeaderFacets(context, writer, colums,
+
+ encodeHeaderFacets(context, writer, table.columns(),
"dr-table-subheadercell rich-table-subheadercell",
headerClass, "header", "th", numberOfColumns);
@@ -218,33 +220,33 @@
* @param attributeName - attribute name
* @return true if specified attribute should generate header on the table
*/
- public boolean isHeaderFactoryColumnAttributePresent(UIDataTable table, String
attributeName) {
- Iterator<UIComponent> columns = table.columns();
- boolean result = false;
+ public boolean isHeaderFactoryColumnAttributePresent(UIDataTable table,
+ String attributeName) {
+ Iterator<UIComponent> columns = table.columns();
+ boolean result = false;
+
+ while (columns.hasNext() && !result) {
+ UIComponent column = columns.next();
+ if (isColumnRendered(column)) {
+ if (null != column.getValueExpression(attributeName)) {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
- while (columns.hasNext() && !result) {
- UIComponent column = columns.next();
- if (isColumnRendered(column)) {
- if (null != column.getValueExpression(attributeName)) {
- result = true;
- }
- }
- }
- return result;
- }
-
/**
* @param component
* @return
*/
protected boolean isColumnRendered(UIComponent component) {
- boolean rendered = true;
try {
- rendered = component.isRendered();
+ return component.isRendered();
} catch(Exception e){
// DO nothing, rendered binded to row variable;
}
- return rendered;
+ return true;
}
protected void encodeHeaderFacets(FacesContext context,
@@ -258,46 +260,45 @@
while (headers.hasNext()) {
UIComponent column = (UIComponent) headers.next();
- if (isColumnRendered(column)) {
+ if (!isColumnRendered(column)) {
+ continue;
+ }
- Integer colspan = (Integer) column.getAttributes().get("colspan");
- if (colspan != null) {
- t_colCount += colspan.intValue();
- } else {
- t_colCount++;
- }
-
- if (t_colCount > colCount) {
- break;
- }
+ Integer colspan = (Integer) column.getAttributes().get("colspan");
+ if (colspan != null && colspan.intValue() > 0) {
+ t_colCount += colspan.intValue();
+ } else {
+ t_colCount++;
+ }
+
+ if (t_colCount > colCount) {
+ break;
+ }
- String classAttribute = facetName + "Class";
- String columnHeaderClass = (String) column.getAttributes().get(classAttribute);
-
- writer.startElement(element, column);
- encodeStyleClass(writer, null, skinCellClass, headerClass, columnHeaderClass);
- writer.writeAttribute("scope", "col", null);
- getUtils().encodeAttribute(context, column, "colspan");
+ String classAttribute = facetName + "Class";
+ String columnHeaderClass = (String) column.getAttributes().get(classAttribute);
+
+ writer.startElement(element, column);
+ encodeStyleClass(writer, null, skinCellClass, headerClass, columnHeaderClass);
+ writer.writeAttribute("scope", "col", null);
+ getUtils().encodeAttribute(context, column, "colspan");
- boolean sortableColumn = column.getValueExpression("comparator") != null
- || column.getValueExpression("sortBy") != null;
+ boolean sortableColumn = column.getValueExpression("comparator") != null
+ || column.getValueExpression("sortBy") != null;
- HeaderEncodeStrategy strategy = (column instanceof org.richfaces.component.UIColumn
- && "header".equals(facetName)) ? richEncodeStrategy :
simpleEncodeStrategy;
+ HeaderEncodeStrategy strategy = (column instanceof org.richfaces.component.UIColumn
+ && "header".equals(facetName)) ? richEncodeStrategy :
simpleEncodeStrategy;
- strategy.encodeBegin(context, writer, column, facetName, sortableColumn);
+ strategy.encodeBegin(context, writer, column, facetName, sortableColumn);
- UIComponent facet = column.getFacet(facetName);
- if (facet != null && isColumnRendered(facet)) {
- renderChild(context, facet);
- }
-
- strategy.encodeEnd(context, writer, column, facetName, sortableColumn);
-
- writer.endElement(element);
-
+ UIComponent facet = column.getFacet(facetName);
+ if (facet != null && isColumnRendered(facet)) {
+ renderChild(context, facet);
}
+ strategy.encodeEnd(context, writer, column, facetName, sortableColumn);
+
+ writer.endElement(element);
}
}
@@ -475,8 +476,7 @@
count = currentLength;
}
// Calculate number of columns in row.
- currentLength = calculateRowColumns(((Row) column)
- .columns());
+ currentLength = calculateRowColumns(((Row) column).columns());
// Store max calculated value
if (currentLength > count) {
count = currentLength;
@@ -491,11 +491,9 @@
}
currentLength = 0;
}
- Integer colspan = (Integer) column.getAttributes().get(
- "colspan");
+ Integer colspan = (Integer) column.getAttributes().get("colspan");
// Append colspan of this column
- if (null != colspan
- && colspan.intValue() != Integer.MIN_VALUE) {
+ if (null != colspan && colspan.intValue() != Integer.MIN_VALUE) {
currentLength += colspan.intValue();
} else {
currentLength++;
@@ -504,7 +502,6 @@
// UIColumn always have colspan == 1.
currentLength++;
}
-
}
}
if (currentLength > count) {
@@ -641,14 +638,14 @@
@SuppressWarnings("unchecked")
Map<String, Object> parameters =
- (Map<String, Object>) eventOptions.get("parameters");
+ (Map<String, Object>) eventOptions.get("parameters");
-
parameters.put(id, SORT_FILTER_PARAMETER);
if (sortable) {
parameters.put(SORT_FILTER_PARAMETER, column.getClientId(context));
}
ajaxFunction.addParameter(eventOptions);
+
StringBuffer buffer = new StringBuffer();
ajaxFunction.appendScript(buffer);
@@ -757,16 +754,11 @@
if (imageUrl != null) {
writer.startElement(HTML.IMG_ELEMENT, column);
- writer.writeAttribute(HTML.src_ATTRIBUTE, imageUrl,
- null);
- writer.writeAttribute(HTML.alt_ATTRIBUTE, " ",
- null);
+ writer.writeAttribute(HTML.src_ATTRIBUTE, imageUrl, null);
+ writer.writeAttribute(HTML.alt_ATTRIBUTE, " ", null);
writer.writeAttribute(HTML.width_ATTRIBUTE, "15", null);
- writer
- .writeAttribute(HTML.height_ATTRIBUTE, "15",
- null);
- writer.writeAttribute(HTML.class_ATTRIBUTE,
- "dr-table-header-sort-img rich-sort-icon", null);
+ writer.writeAttribute(HTML.height_ATTRIBUTE, "15", null);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "dr-table-header-sort-img
rich-sort-icon", null);
writer.endElement(HTML.IMG_ELEMENT);
}
writer.endElement(HTML.SPAN_ELEM);