Author: sergeyhalipov
Date: 2008-02-25 12:37:22 -0500 (Mon, 25 Feb 2008)
New Revision: 6326
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
trunk/ui/dataTable/src/main/resources/org/richfaces/renderkit/html/css/table.xcss
Log:
Inplace inputs in headers with filter. HTML mark-up changed.
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java 2008-02-25
17:23:53 UTC (rev 6325)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/component/UIDataTable.java 2008-02-25
17:37:22 UTC (rev 6326)
@@ -57,6 +57,8 @@
Collection<Object> sortPriority = new ArrayList<Object>();
+ private boolean hasFilterColumns = false;
+
/**
* @author shura
*
@@ -255,4 +257,12 @@
super.restoreState(context, states[0]);
sortPriority = (Collection)states[1];
}
+
+ public boolean hasFilterColumns() {
+ return hasFilterColumns;
+ }
+
+ public void setHasFilterColumns(boolean hasFilterColumns) {
+ this.hasFilterColumns = hasFilterColumns;
+ }
}
\ No newline at end of file
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2008-02-25
17:23:53 UTC (rev 6325)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2008-02-25
17:37:22 UTC (rev 6326)
@@ -100,6 +100,7 @@
if (header != null ||headers.hasNext()) {
writer.startElement("thead", table);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "dr-table-thead", null);
String headerClass = (String) table.getAttributes().get(
"headerClass");
if (header != null) {
@@ -111,6 +112,7 @@
}
if (headers.hasNext()&&findFacet(table,"header")) {
+ table.setHasFilterColumns(false);
writer.startElement("tr", table);
encodeStyleClass(writer, null,
"dr-table-subheader rich-table-subheader", null,
@@ -120,6 +122,17 @@
headerClass, "header", "th", colCount);
writer.endElement("tr");
+
+ if (table.hasFilterColumns()) {
+ colums = table.columns();
+ writer.startElement("tr", table);
+ encodeStyleClass(writer, null,
+ "dr-table-subheader rich-table-subheader", null,
+ headerClass);
+ encodeFilterInputs(context, writer, colums, "dr-table-subheadercell
rich-table-subheadercell",
+ "th", headerClass, colCount);
+ writer.endElement("tr");
+ }
}
writer.endElement("thead");
}
@@ -234,7 +247,8 @@
StringBuffer buffer = new StringBuffer();
ajaxFunction.appendScript(buffer);
- encodeInplaceInput(context, column, buffer);
+ ((UIDataTable)table).setHasFilterColumns(true);
+ addInplaceInput(context, column, buffer);
}
}
writer.endElement(element);
@@ -540,7 +554,7 @@
}
}
- protected void encodeInplaceInput(FacesContext context, UIComponent column, StringBuffer
buffer)
+ protected void addInplaceInput(FacesContext context, UIComponent column, StringBuffer
buffer)
throws IOException {
UIInput filterValueInput = (UIInput)column.getFacet(FILTER_INPUT_FACET_NAME);
String event = "onviewactivated";
@@ -558,9 +572,36 @@
}
filterValueInput.getAttributes().put(event, buffer.toString());
filterValueInput.setValue(column.getAttributes().get("filterValue"));
-
- getUtils().encodeBeginFormIfNessesary(context, column);
- renderChild(context, filterValueInput);
- getUtils().encodeEndFormIfNessesary(context, column);
}
+
+ protected void encodeFilterInputs(FacesContext context,
+ ResponseWriter writer, Iterator<UIComponent> columns, String cellClass,
+ String element, String headerClass, int colCount) throws IOException {
+ int t_colCount = 0;
+ while (columns.hasNext()) {
+ UIComponent column = (UIComponent) columns.next();
+ if ((Integer)column.getAttributes().get("colspan") != null ) {
+ t_colCount = t_colCount +
((Integer)column.getAttributes().get("colspan")).intValue();
+ } else {
+ t_colCount++;
+ }
+ if( t_colCount > colCount) {
+ break;
+ }
+
+ String columnHeaderClass = (String)
column.getAttributes().get("headerClass");
+ writer.startElement(element, column);
+ encodeStyleClass(writer, null, cellClass, headerClass,
+ columnHeaderClass);
+ writer.writeAttribute("scope", "col", null);
+ getUtils().encodeAttribute(context, column, "colspan");
+
+ UIInput filterValueInput = (UIInput) column.getFacet(FILTER_INPUT_FACET_NAME);
+ if (null != filterValueInput) {
+ getUtils().encodeBeginFormIfNessesary(context, column);
+ renderChild(context, filterValueInput);
+ getUtils().encodeEndFormIfNessesary(context, column);
+ }
+ }
+ }
}
\ No newline at end of file
Modified:
trunk/ui/dataTable/src/main/resources/org/richfaces/renderkit/html/css/table.xcss
===================================================================
---
trunk/ui/dataTable/src/main/resources/org/richfaces/renderkit/html/css/table.xcss 2008-02-25
17:23:53 UTC (rev 6325)
+++
trunk/ui/dataTable/src/main/resources/org/richfaces/renderkit/html/css/table.xcss 2008-02-25
17:37:22 UTC (rev 6326)
@@ -81,12 +81,15 @@
<u:style name="background-color"
skin="additionalBackgroundColor"/> <!--additionalBackgroundColor-->
</u:selector>
-<u:selector name=".dr-table-subheadercell" >
- <u:style name="border-right" value="solid">
<!--tableBorderColor-->
+<u:selector name=".dr-table-thead" >
+ <u:style name="border-bottom" value="solid">
<!--tableBorderColor-->
<f:verbatim skin="tableBorderWidth" />
<f:verbatim skin="tableBorderColor" />
</u:style>
- <u:style name="border-bottom" value="solid">
<!--tableBorderColor-->
+</u:selector>
+
+<u:selector name=".dr-table-subheadercell" >
+ <u:style name="border-right" value="solid">
<!--tableBorderColor-->
<f:verbatim skin="tableBorderWidth" />
<f:verbatim skin="tableBorderColor" />
</u:style>