Author: abelevich
Date: 2010-05-07 05:56:57 -0400 (Fri, 07 May 2010)
New Revision: 16916
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.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/DataTableRowsRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js
Log:
add client-api for the sorting/filtering func
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2010-05-07
06:47:19 UTC (rev 16915)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2010-05-07
09:56:57 UTC (rev 16916)
@@ -66,6 +66,7 @@
public void encodeColumnStart(ResponseWriter writer, FacesContext context, String
parentId, UIComponent component) throws IOException {
writer.startElement(getCellElement(context, parentId), component);
+ getUtils().encodeId(context, component);
String cellClass = getCellClass(context, parentId);
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, cellClass);
@@ -127,7 +128,7 @@
public void encodeFirstRowStart(ResponseWriter writer, FacesContext context, String
parentId, UIComponent component) throws IOException {
writer.startElement(HTML.TR_ELEMENT, component);
- getUtils().encodeId(context, component);
+// getUtils().encodeId(context, component);
String styleClass = getFirstRowClass(context, parentId);
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
}
@@ -138,7 +139,7 @@
public void encodeRowStart(ResponseWriter writer, FacesContext context, String
parentId, UIComponent component) throws IOException {
writer.startElement(HTML.TR_ELEMENT, component);
- getUtils().encodeId(context, component);
+// getUtils().encodeId(context, component);
String styleClass = getRowClass(context, parentId);
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
}
@@ -182,14 +183,14 @@
public void encodeStyleClass(ResponseWriter writer, FacesContext context, UIComponent
component,
String styleClassAttribute, String styleClass) throws IOException {
- boolean isEmpty = isEmptyAttr(component, styleClassAttribute);
- if (isEmpty && !(styleClass != null &&
styleClass.trim().length() != 0)) {
- return;
- }
+ boolean isEmpty = isEmptyAttr(component, styleClassAttribute);
+ if (isEmpty && !(styleClass != null && styleClass.trim().length()
!= 0)) {
+ return;
+ }
- String componentStyleClass = isEmpty ? styleClass : styleClass + "
"
- + component.getAttributes().get(styleClassAttribute);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, componentStyleClass, null);
+ String componentStyleClass = isEmpty ? styleClass : styleClass + " "
+ + component.getAttributes().get(styleClassAttribute);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, componentStyleClass, null);
}
protected boolean isEmptyAttr(UIComponent component, String attribute) {
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 2010-05-07
06:47:19 UTC (rev 16915)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-05-07
09:56:57 UTC (rev 16916)
@@ -24,9 +24,6 @@
public static final String CELL_CLASS = "cellClass";
- public static final String SORTING = "sorting";
-
-
@Override
protected void doDecode(FacesContext context, UIComponent component) {
decodeSortingFiltering(context, component);
@@ -114,23 +111,14 @@
}
public void encodeTableEnd(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException {
- writer.endElement(HTML.TABLE_ELEMENT);
encodeClientScript(writer, context, component);
- encodeSortHiddenInput(writer, context, component);
+ writer.endElement(HTML.TABLE_ELEMENT);
}
- public void encodeSortHiddenInput(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException {
- writer.startElement(HTML.INPUT_ELEM, component);
- String clientId = component.getClientId() + ":sort";
- writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId , null);
- writer.writeAttribute(HTML.TYPE_ATTR, "hidden", null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId, null);
- writer.writeAttribute(HTML.VALUE_ATTRIBUTE, null, null);
- writer.endElement(HTML.INPUT_ELEM);
- }
public abstract void encodeClientScript(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException;
-
+
+
public void encodeTableBodyStart(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable)
throws IOException {
writer.startElement(HTML.TBOBY_ELEMENT, dataTable);
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRowsRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRowsRenderer.java 2010-05-07
06:47:19 UTC (rev 16915)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRowsRenderer.java 2010-05-07
09:56:57 UTC (rev 16916)
@@ -19,9 +19,9 @@
public abstract class DataTableRowsRenderer extends AbstractRowsRenderer {
- private static final String FILTERING_STRING = "rich:filterString";
+ private static final String FILTERING_STRING = "rich:filtering";
- private static final String SORTING_STRING = "rich:sortString";
+ private static final String SORTING_STRING = "rich:sorting";
private static final String SEPARATOR = ":";
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js 2010-05-07
06:47:19 UTC (rev 16915)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js 2010-05-07
09:56:57 UTC (rev 16916)
@@ -5,18 +5,50 @@
richfaces.ui.DataTable = function(id, options) {
this.id = id;
this.options = options;
-
- $super.constructor.call(this,id);
+ $super.constructor.call(this,id);
$p.attachToDom.call(this, id);
};
var $super = richfaces.BaseComponent.extend(richfaces.BaseComponent,
richfaces.ui.DataTable);
var $p =
richfaces.BaseComponent.extend(richfaces.BaseComponent,richfaces.ui.DataTable, {});
var $super = richfaces.ui.DataTable.$super;
-
- $.extend(richfaces.ui.DataTable.prototype, ( function () {
- return {
+
+ $.extend(richfaces.ui.DataTable, {
+ SORTING: "rich:sorting",
+ FILTERING: "rich:filtering"
+ });
+
+ $.extend(richfaces.ui.DataTable.prototype, ( function () {
+ var invoke = function(event, attributes) {
+ richfaces.ajax(this.id, event, {"parameters" : attributes});
+ };
+
+ var createParameters = function(type, id, arg1, arg2) {
+ var parameters = {};
+ var key = this.id + type;
+ parameters[key] = ((id || "") + ":" + (arg1 ||
"") + ":" + (arg2 || true));
+
+ var eventOptions = this.options.ajaxEventOption;
+ for (key in eventOptions) {
+ if(!parameters[key]) {
+ parameters[key] = eventOptions[key];
+ }
+ }
+ return parameters;
+ };
+
+ return {
+
+ name : "RichFaces.ui.DataTable",
+
+ sort: function(columnId, direction, isClear) {
+
invoke.call(this,null,createParameters.call(this,richfaces.ui.DataTable.SORTING,
columnId, direction, isClear));
+ },
+
+ filter: function(columnId, filterValue, isClear) {
+
invoke.call(this,createParameters.call(this,richfaces.ui.DataTable.FILTERING, columnId,
filterValue, isClear));
+ }
}
})());