Author: konstantin.mishin
Date: 2010-03-19 14:04:19 -0400 (Fri, 19 Mar 2010)
New Revision: 16638
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
Log:
RF-8484
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2010-03-19
17:31:27 UTC (rev 16637)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2010-03-19
18:04:19 UTC (rev 16638)
@@ -1,8 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
package org.richfaces.component;
+import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.RepeatState;
+
+
/**
* @author Anton Belevich
*
*/
-public abstract class UIExtendedDataTable extends UIDataTable {
+public abstract class UIExtendedDataTable extends UIDataTableBase {
+
+ @Override
+ protected DataComponentState createComponentState() {
+ return new RepeatState() {
+ @Override
+ public int getFirst() {
+ return UIExtendedDataTable.this.getClientFirst();
+ }
+
+ @Override
+ public int getRows() {
+ return UIExtendedDataTable.this.getClientRows();
+ }
+ };
+ }
+
+ protected enum PropertyKeys {
+ clientFirst, clientRows
+ }
+
+ public int getClientFirst() {
+ return (Integer) getStateHelper().eval(PropertyKeys.clientFirst, 0);
+ }
+
+ public void setClientFirst(int clientFirst) {
+ getStateHelper().put(PropertyKeys.clientFirst, clientFirst);
+ }
+
+ @Override
+ public void setFirst(int first) {
+ super.setFirst(first);
+ setClientFirst(first);
+ }
+
+ public int getClientRows() {
+ return (Integer) getStateHelper().eval(PropertyKeys.clientRows, 0);
+ }
+
+ public void setClientRows(int clientRows) {
+ getStateHelper().put(PropertyKeys.clientRows, clientRows);
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-03-19
17:31:27 UTC (rev 16637)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-03-19
18:04:19 UTC (rev 16638)
@@ -203,12 +203,25 @@
ajaxFunction.addParameter(eventOptions);
}
- writer.write("new RichFaces.ExtendedDataTable('" +
component.getClientId(context)
- + "', function(event, columnsOrder) {" +
ajaxFunction.toScript() + ";});");
+ writer.write("new RichFaces.ExtendedDataTable('" +
component.getClientId(context) + "', "
+ + getRowCount(component) + ", function(event, columnsOrder) {" +
ajaxFunction.toScript() + ";});");
writer.endElement(HTML.SCRIPT_ELEM);
writer.endElement(HTML.DIV_ELEM);
}
+
+ private int getRowCount(UIComponent component) {
+ UIExtendedDataTable table = (UIExtendedDataTable) component;
+ int rows = table.getRows();
+ int rowCount = table.getRowCount() - table.getFirst();
+ if (rows > 0) {
+ rows = Math.min(rows, rowCount);
+ } else {
+ rows = rowCount;
+ }
+ return rows;
+ }
+
private void encodeStyle(RendererState state) throws IOException {
FacesContext context = state.getContext();
ResponseWriter writer = context.getResponseWriter();
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2010-03-19
17:31:27 UTC (rev 16637)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2010-03-19
18:04:19 UTC (rev 16638)
@@ -34,10 +34,10 @@
return rule;
};
- richfaces.ExtendedDataTable = function(id, ajaxFunction) {
+ richfaces.ExtendedDataTable = function(id, rowCount, ajaxFunction) {
var WIDTH_CLASS_NAME_BASE = "rich-extable-cell-width-";
var MIN_WIDTH = 20;
- var idSuffixs = [":header", ":footer"];
+ var idSuffixs = [":header", ":footer"]; //TODO Not use idSuffixs
var element = document.getElementById(id);
var bodyElement = document.getElementById(id + ":b");
@@ -57,7 +57,7 @@
idSuffixs[idSuffixs.length] = ":body";
//TODO var marginElement = contentElement.firstChild;this.marginElement =
Richfaces.firstDescendant(this.contentElement);
var dataTableElement = contentElement.lastChild;//TODO this.dataTableElement =
Richfaces.lastDescendant(this.contentElement);
- var rows = document.getElementById(id + idSuffixs[1]).firstChild.rows.length;//TODO
Richfaces.firstDescendant;
+ var rows = document.getElementById(id +
":body").firstChild.rows.length;//TODO Richfaces.firstDescendant;
}
var scrollElement = document.getElementById(id + ":footer");
@@ -135,7 +135,7 @@
};
var initializeLayout = function() {
- //TODO contentElement.style.height = (rowCount * dataTableElement.offsetHeight / rows)
+ "px";
+ contentElement.style.height = (rowCount * dataTableElement.offsetHeight / rows) +
"px";
updateLayout();
updateScrollPosition(); //TODO Restore horizontal scroll position
};
@@ -217,16 +217,6 @@
}
});
ajaxFunction(event, colunmsOrder);
-// bodyElement.style.display = "none";
-// jQuery("#" + escapedId + "\\:" + classNameOfReorderingColumn +
"\\:h").insertBefore("#" + escapedId + "\\:" + className +
"\\:h");
-// jQuery(bodyElement).find("table div tr").each(function(){
-// var div = jQuery(this).find("." + WIDTH_CLASS_NAME_BASE +
classNameOfReorderingColumn);
-// if (div.length) {
-// div.parent().insertBefore(jQuery(this).find("." + WIDTH_CLASS_NAME_BASE
+ className).parent());
-// }
-// });
-// jQuery("#" + escapedId + "\\:" + classNameOfReorderingColumn +
"\\:f").insertBefore("#" + escapedId + "\\:" + className +
"\\:f");
-// bodyElement.style.display = "";
};
var cancelReorder = function(event) {