Author: Alex.Kolonitsky
Date: 2009-03-03 09:19:50 -0500 (Tue, 03 Mar 2009)
New Revision: 12802
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxFormTest.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxValidatorTest.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataTableTest.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
trunk/ui/dataTable/src/test/java/org/richfaces/renderkit/DataTableRenderingTest.java
Log:
DataTable: .rich-table-firstrow is used for all rows and not the first one
https://jira.jboss.org/jira/browse/RF-5007
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxFormTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxFormTest.java 2009-03-03
14:07:09 UTC (rev 12801)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxFormTest.java 2009-03-03
14:19:50 UTC (rev 12802)
@@ -44,18 +44,8 @@
private final static String NEXT_TEXT = "after submit";
- private final static String CHECK_ID_AJAXSUBMIT = "ajaxSubmit";
-
- private final static String CHECK_ID_IGNOREDUPRESPONSES =
"ignoreDupResponses";
-
- private final static String CHECK_ID_PREPENDID = "prependId";
-
private final static String CHECK_ID_RENDERED = "rendered";
- private final static String PANEL_GROUP = "content";
-
- private final static String RERENDER_ID = "rerender";
-
private final static String LINK_ID = "link";
private final static String RESET_METHOD = "#{formBean.reset}";
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxValidatorTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxValidatorTest.java 2009-03-03
14:07:09 UTC (rev 12801)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxValidatorTest.java 2009-03-03
14:19:50 UTC (rev 12802)
@@ -20,8 +20,6 @@
*/
package org.richfaces.testng;
-import junit.framework.Assert;
-
import org.ajax4jsf.template.Template;
import org.richfaces.SeleniumTestBase;
import org.testng.annotations.Test;
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataTableTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataTableTest.java 2009-03-03
14:07:09 UTC (rev 12801)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataTableTest.java 2009-03-03
14:19:50 UTC (rev 12802)
@@ -349,20 +349,16 @@
int rowCount = values.length;
assertRowsCount(rowCount, dataTableId);
- int i = 0;
- String [] actualValues = new String[values.length];
- for (String v : values) {
+ String [] actualValues = new String[rowCount];
+ for (int i = 0; i < rowCount; i++) {
actualValues[i] = getCellText(i, columns);
- i++;
}
- i = 0;
- for (String v : values) {
- if (!v.equals(actualValues[i])) {
+
+ for (int i = 0; i < rowCount; i++) {
+ if (!values[i].equals(actualValues[i])) {
Assert.fail("Columns was sorted incorectly. Expected: " +
toString(values) + " But was: " + toString(actualValues));
}
- i++;
}
-
}
private void clickSort(int column) {
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
---
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-03-03
14:07:09 UTC (rev 12801)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-03-03
14:19:50 UTC (rev 12802)
@@ -197,12 +197,14 @@
protected void encodeStyleClass(ResponseWriter writer, Object parentPredefined,
Object predefined, Object parent, Object custom) throws IOException {
StringBuffer styleClass = new StringBuffer();
+
// Construct predefined classes
if (null != parentPredefined) {
styleClass.append(parentPredefined).append(" ");
} else if (null != predefined) {
styleClass.append(predefined).append(" ");
}
+
// Append class from parent component.
if (null != parent) {
styleClass.append(parent).append(" ");
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-03-03
14:07:09 UTC (rev 12801)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-03-03
14:19:50 UTC (rev 12802)
@@ -341,7 +341,7 @@
UIDataTable table = (UIDataTable) holder.getTable();
ResponseWriter writer = context.getResponseWriter();
Iterator<UIComponent> iter = table.columns();
- boolean first = true;
+ boolean first = holder.getRowCounter() == 0;
int currentColumn = 0;
UIComponent column = null;
while (iter.hasNext()) {
@@ -349,8 +349,8 @@
// Start new row for first column - expect a case of the detail
// table, wich will be insert own row.
if (first && !(column instanceof Row)) {
- encodeRowStart(context, getFirstRowSkinClass(), holder
- .getRowClass(), table, writer);
+ encodeRowStart(context, getFirstRowSkinClass(),
+ holder.getRowClass(), table, writer);
}
if (column instanceof Column) {
boolean breakBefore = ((Column) column).isBreakBefore()
@@ -364,15 +364,14 @@
// will be insert own row.
if (!(column instanceof Row)) {
holder.nextRow();
- encodeRowStart(context, holder.getRowClass(), table,
- writer);
+ encodeRowStart(context, holder.getRowClass(), table, writer);
}
}
+
encodeCellChildren(context, column,
first ? getFirstRowSkinClass() : null,
getRowSkinClass(), holder.getRowClass(),
- getCellSkinClass(), holder
- .getColumnClass(currentColumn));
+ getCellSkinClass(), holder.getColumnClass(currentColumn));
// renderChild(context, column);
if ((column instanceof Row) && iter.hasNext()) {
// Start new row for remained columns.
@@ -386,8 +385,8 @@
writer.startElement(HTML.td_ELEM, table);
getUtils().encodeId(context, column);
String columnClass = holder.getColumnClass(currentColumn);
- encodeStyleClass(writer, null, getCellSkinClass(), null,
- columnClass);
+ encodeStyleClass(writer, null, getCellSkinClass(), null, columnClass);
+
// TODO - encode column attributes.
renderChildren(context, column);
writer.endElement(HTML.td_ELEM);
Modified:
trunk/ui/dataTable/src/test/java/org/richfaces/renderkit/DataTableRenderingTest.java
===================================================================
---
trunk/ui/dataTable/src/test/java/org/richfaces/renderkit/DataTableRenderingTest.java 2009-03-03
14:07:09 UTC (rev 12801)
+++
trunk/ui/dataTable/src/test/java/org/richfaces/renderkit/DataTableRenderingTest.java 2009-03-03
14:19:50 UTC (rev 12802)
@@ -66,7 +66,21 @@
}
/*
- * (non-Javadoc)
+ * <form>
+ * <dataTable id="dataTable" value="List<Date>">
+ * <columnGroup>
+ * <column>
+ * <outputText column="" />
+ * <column>
+ * <column>
+ * <outputLink value="" />
+ * <column>
+ * </columnGroup>
+ * <column>
+ * <output value="value" />
+ * </column>
+ * </dataTable>
+ * </form>
*
* @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
*/
@@ -75,9 +89,24 @@
form = new HtmlForm();
form.setId("form");
+ form.getChildren().add(getDataTable());
+
facesContext.getViewRoot().getChildren().add(form);
- dataTable = (UIDataTable) application
- .createComponent("org.richfaces.DataTable");
+ }
+
+ /*
+ * <dataTable id="dataTable" value="List<Date>">
+ * <columnGroup>
+ * ...
+ * </columnGroup>
+ * <column>
+ * <output value="value" />
+ * </column>
+ * </dataTable>
+ *
+ * */
+ private UIDataTable getDataTable() {
+ dataTable = (UIDataTable)
application.createComponent("org.richfaces.DataTable");
dataTable.setId("dataTable");
List<Date> list = new ArrayList<Date>();
@@ -86,36 +115,51 @@
}
dataTable.setValue(new ListDataModel(list));
- columnGroup = (UIColumnGroup) application
- .createComponent("org.richfaces.ColumnGroup");
- dataTable.getChildren().add(columnGroup);
+ dataTable.getChildren().add(getColumnGroup());
+ dataTable.getChildren().add(getColumn3());
+
+ return dataTable;
+ }
- column1 = (UIColumn) application
- .createComponent("org.richfaces.Column");
- UIOutput cellElement1 = (UIOutput) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
- null, null, null);
+ private javax.faces.component.UIColumn getColumn3() {
+ javax.faces.component.UIColumn column3 = new javax.faces.component.UIColumn();
+ column3.setId("column3");
+ UIOutput cellElement3 = (UIOutput)
application.createComponent(UIOutput.COMPONENT_TYPE);
+ cellElement3.setValue("value");
+ column3.getChildren().add(cellElement3);
+ return column3;
+ }
+
+ /*
+ * <columnGroup>
+ * <column>
+ * <outputText column="" />
+ * <column>
+ * <column>
+ * <outputLink value="" />
+ * <column>
+ * </columnGroup>
+ *
+ * */
+ private UIColumnGroup getColumnGroup() {
+ columnGroup = (UIColumnGroup)
application.createComponent("org.richfaces.ColumnGroup");
+ columnGroup.setId("columnGroup");
+
+ column1 = (UIColumn)
application.createComponent("org.richfaces.Column");
+ column1.setId("column1");
+ UIOutput cellElement1 = (UIOutput) createComponent(HtmlOutputText.COMPONENT_TYPE,
HtmlOutputText.class.getName(),null, null, null);
cellElement1.setValueExpression("column", new
ColumnValueExpression());
column1.getChildren().add(cellElement1);
columnGroup.getChildren().add(column1);
- column2 = (UIColumn) application
- .createComponent("org.richfaces.Column");
- UIOutput cellElement2 = (UIOutput) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputLink.class.getName(),
- null, null, null);
+ column2 = (UIColumn)
application.createComponent("org.richfaces.Column");
+ column2.setId("column2");
+ UIOutput cellElement2 = (UIOutput) createComponent(HtmlOutputText.COMPONENT_TYPE,
HtmlOutputLink.class.getName(),null, null, null);
cellElement2.setValueExpression("value", new ColumnValueExpression());
column2.getChildren().add(cellElement2);
- columnGroup.getChildren().add(column2);
+ columnGroup.getChildren().add(column2);
- javax.faces.component.UIColumn column3 = new javax.faces.component.UIColumn();
- UIOutput cellElement3 = (UIOutput)
application.createComponent(UIOutput.COMPONENT_TYPE);
- cellElement3.setValue("value");
- column3.getChildren().add(cellElement3);
- dataTable.getChildren().add(column3);
-
- form.getChildren().add(dataTable);
-
+ return columnGroup;
}
/*
@@ -138,56 +182,64 @@
* @throws Exception
*/
public void testRenderDataTable() throws Exception {
-
+ // setUp
dataTable.getAttributes().put("columnsWidth",
"400px,200px");
- UIColumn column3 = (UIColumn) application
- .createComponent("org.richfaces.Column");
+ UIColumn column3 = (UIColumn)
application.createComponent("org.richfaces.Column");
+ column3.setId("local_column3");
dataTable.getChildren().add(column3);
- UIOutput text = (UIOutput) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
- null, null, null);
+ UIOutput text = (UIOutput) createComponent(HtmlOutputText.COMPONENT_TYPE,
HtmlOutputText.class.getName(),null, null, null);
text.setValue("Column");
column3.getChildren().add(text);
column3.setBreakBefore(true);
- UIColumn column4 = (UIColumn) application
- .createComponent("org.richfaces.Column");
+ UIColumn column4 = (UIColumn)
application.createComponent("org.richfaces.Column");
+ column4.setId("local_column4");
dataTable.getChildren().add(column4);
- UIOutput text2 = (UIOutput) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
- null, null, null);
+ UIOutput text2 = (UIOutput) createComponent(HtmlOutputText.COMPONENT_TYPE,
HtmlOutputText.class.getName(),null, null, null);
text.setValue("Column2");
column4.getChildren().add(text2);
column4.setRendered(false);
+ // test
HtmlPage page = renderView();
+// System.out.println(page.asXml());
+
assertNotNull(page);
- HtmlElement table = page.getHtmlElementById(dataTable
- .getClientId(facesContext));
+ HtmlElement table =
page.getHtmlElementById(dataTable.getClientId(facesContext));
assertNotNull(table);
assertEquals("table", table.getNodeName());
String classAttr = table.getAttributeValue("class");
assertTrue(classAttr.contains("dr-table rich-table"));
- List<HtmlElement> elements =
table.getHtmlElementsByTagName("col");
+ List<?> elements = table.getHtmlElementsByTagName("col");
assertEquals(2, elements.size());
classAttr = ((HtmlElement)
elements.get(0)).getAttributeValue("width");
assertTrue(classAttr.contains("400px"));
classAttr = ((HtmlElement)
elements.get(1)).getAttributeValue("width");
assertTrue(classAttr.contains("200px"));
- List<HtmlElement> bodies =
table.getHtmlElementsByTagName("tbody");
+ List<?> bodies = table.getHtmlElementsByTagName("tbody");
assertEquals(1, bodies.size());
- List<HtmlElement> trs = ((HtmlElement)
bodies.get(0)).getHtmlElementsByTagName("tr");
+ List<?> trs = ((HtmlElement)
bodies.get(0)).getHtmlElementsByTagName("tr");
assertTrue(trs.size() > 0);
HtmlElement tr = (HtmlElement) trs.get(0);
assertNotNull(tr);
classAttr = tr.getAttributeValue("class");
assertTrue(classAttr.contains("dr-table-firstrow
rich-table-firstrow"));
+ for (int i = 1; i < trs.size(); i++) {
+ tr = (HtmlElement) trs.get(i);
+ assertNotNull(tr);
+ classAttr = tr.getAttributeValue("class");
+
+ assertFalse("Row i = " + i + " have
'dr-table-firstrow' style",
+ classAttr.contains("dr-table-firstrow"));
+ assertFalse("Row i = " + i + " have
'rich-table-firstrow' style",
+ classAttr.contains("rich-table-firstrow"));
+ }
- Iterator<HtmlElement> tds = tr.getChildIterator();
+ Iterator<?> tds = tr.getChildIterator();
assertTrue(tds.hasNext());
HtmlElement td = (HtmlElement) tds.next();
assertNotNull(td);
@@ -201,54 +253,41 @@
* @throws Exception
*/
public void testRenderDataTableFacets() throws Exception {
-
- UIColumnGroup header1 = (UIColumnGroup) application
- .createComponent("org.richfaces.ColumnGroup");
+
+ UIColumnGroup header1 = (UIColumnGroup)
application.createComponent("org.richfaces.ColumnGroup");
header1.getAttributes().put("columnClasses", "cola, colb");
dataTable.getFacets().put("header", header1);
- UIColumn headerColumn1 = (UIColumn) application
- .createComponent("org.richfaces.Column");
- UIOutput headerText1 = (UIOutput) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
- null, null, null);
+ UIColumn headerColumn1 = (UIColumn)
application.createComponent("org.richfaces.Column");
+ UIOutput headerText1 = (UIOutput) createComponent(HtmlOutputText.COMPONENT_TYPE,
HtmlOutputText.class.getName(),null, null, null);
headerText1.setValue("Header Column1");
headerColumn1.getChildren().add(headerText1);
header1.getChildren().add(headerColumn1);
- UIOutput column1header = (UIOutput) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
- null, null, null);
+ UIOutput column1header = (UIOutput)
createComponent(HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),null, null,
null);
column1header.setValue("Column1 Header");
headerColumn1.getFacets().put("header", column1header);
- UIColumn headerColumn2 = (UIColumn) application
- .createComponent("org.richfaces.Column");
- UIOutput headerText2 = (UIOutput) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
- null, null, null);
+ UIColumn headerColumn2 = (UIColumn)
application.createComponent("org.richfaces.Column");
+ UIOutput headerText2 = (UIOutput) createComponent(HtmlOutputText.COMPONENT_TYPE,
HtmlOutputText.class.getName(),null, null, null);
headerText2.setValue("Header Column2");
headerColumn2.getChildren().add(headerText2);
header1.getChildren().add(headerColumn2);
- UIOutput column2header = (UIOutput) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
- null, null, null);
+ UIOutput column2header = (UIOutput)
createComponent(HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),null, null,
null);
column2header.setValue("Column2 Header");
headerColumn2.getFacets().put("header", column2header);
- UIOutput caption = (UIOutput) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
- null, null, null);
+ UIOutput caption = (UIOutput) createComponent(HtmlOutputText.COMPONENT_TYPE,
HtmlOutputText.class.getName(),null, null, null);
dataTable.getFacets().put("caption", caption);
caption.setValue("Caption");
- UIOutput footer = (UIOutput) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
- null, null, null);
+ UIOutput footer = (UIOutput) createComponent(HtmlOutputText.COMPONENT_TYPE,
HtmlOutputText.class.getName(),null, null, null);
dataTable.getFacets().put("footer", footer);
footer.setValue("Footer");
+
+ // test
HtmlPage page = renderView();
assertNotNull(page);
@@ -256,35 +295,33 @@
.getClientId(facesContext));
assertNotNull(table);
- List<HtmlElement> captions =
table.getHtmlElementsByTagName("caption");
+ List<?> captions = table.getHtmlElementsByTagName("caption");
assertNotNull(captions);
assertEquals(1, captions.size());
String classAttr = ((HtmlElement) captions.get(0))
.getAttributeValue("class");
assertTrue(classAttr.contains("dr-table-caption rich-table-caption"));
- List<HtmlElement> headers =
table.getHtmlElementsByTagName("thead");
+ List<?> headers = table.getHtmlElementsByTagName("thead");
assertNotNull(headers);
assertEquals(1, headers.size());
- List<HtmlElement> trs = ((HtmlElement) headers.get(0))
- .getHtmlElementsByTagName("tr");
+ List<?> trs = ((HtmlElement)
headers.get(0)).getHtmlElementsByTagName("tr");
assertTrue(trs.size() > 0);
HtmlElement tr = (HtmlElement) trs.get(0);
assertNotNull(tr);
classAttr = tr.getAttributeValue("class");
assertTrue(classAttr.contains("dr-table-header rich-table-header"));
- Iterator<HtmlElement> tds = tr.getChildIterator();
+ Iterator<?> tds = tr.getChildIterator();
assertNotNull(tds);
assertTrue(tds.hasNext());
- HtmlElement td = tds.next();
+ HtmlElement td = (HtmlElement) tds.next();
assertNotNull(td);
classAttr = td.getAttributeValue("class");
- assertTrue(classAttr
- .contains("dr-table-headercell rich-table-headercell"));
+ assertTrue(classAttr.contains("dr-table-headercell
rich-table-headercell"));
assertTrue(classAttr.contains("cola"));
- List<HtmlElement> footers =
table.getHtmlElementsByTagName("tfoot");
+ List<?> footers = table.getHtmlElementsByTagName("tfoot");
assertNotNull(footers);
assertEquals(1, footers.size());
trs = ((HtmlElement) footers.get(0)).getHtmlElementsByTagName("tr");
@@ -296,12 +333,12 @@
tds = tr.getChildIterator();
assertTrue(tds.hasNext());
- td = tds.next();
+ td = (HtmlElement) tds.next();
assertNotNull(td);
classAttr = td.getAttributeValue("class");
assertTrue(classAttr.contains("dr-table-footercell rich-table-footercell
"));
- Iterator fixedChildren = dataTable.fixedChildren();
+ Iterator<?> fixedChildren = dataTable.fixedChildren();
assertNotNull(fixedChildren);
assertTrue(fixedChildren.hasNext());
}
@@ -334,25 +371,24 @@
.getClientId(facesContext));
assertNotNull(table);
- List<HtmlElement> captions =
table.getHtmlElementsByTagName("caption");
+ List<?> captions = table.getHtmlElementsByTagName("caption");
assertNotNull(captions);
assertEquals(1, captions.size());
- String classAttr = ((HtmlElement) captions.get(0))
- .getAttributeValue("class");
+ String classAttr = ((HtmlElement)
captions.get(0)).getAttributeValue("class");
assertTrue(classAttr.contains("captionClass"));
classAttr = ((HtmlElement)
captions.get(0)).getAttributeValue("style");
assertTrue(classAttr.contains("captionStyle"));
- List<HtmlElement> bodies =
table.getHtmlElementsByTagName("tbody");
+ List<?> bodies = table.getHtmlElementsByTagName("tbody");
assertTrue(bodies.size() > 0);
- List<HtmlElement> trs = ((HtmlElement)
bodies.get(0)).getHtmlElementsByTagName("tr");
+ List<?> trs = ((HtmlElement)
bodies.get(0)).getHtmlElementsByTagName("tr");
assertTrue(trs.size() > 0);
HtmlElement tr = (HtmlElement) trs.get(0);
assertNotNull(tr);
classAttr = tr.getAttributeValue("class");
assertTrue(classAttr.contains("row1"));
- List<HtmlElement> tds = tr.getHtmlElementsByTagName("td");
+ List<?> tds = tr.getHtmlElementsByTagName("td");
assertTrue(tds.size() > 0);
HtmlElement td = (HtmlElement) tds.get(0);
assertNotNull(td);