Author: abelevich
Date: 2010-02-19 11:45:49 -0500 (Fri, 19 Feb 2010)
New Revision: 16472
Added:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/PagingEvent.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/PagingListener.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/SortingEvent.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/SortingListener.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Field.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/SortField.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataScroller.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/behavior/
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/behavior/ToggleBehavior.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/facelets/
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/facelets/tag/
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/facelets/tag/ToggleHandler.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataScrollerRenderBase.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TogglerBehaviorRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/taglib/DataTableHandler.java
Modified:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/component/Expandable.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/ToggleListener.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/visual/ColumnVisualModel.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/visual/SortingFilteringVisualModel.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/FixedChildrenIterator.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/SubtableFixedChildrenIterator.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlExtendedDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSubTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/DataTableState.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/SubTableState.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/ColumnVisualModelImpl.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/SortingFilteringVisualModelImpl.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/ColumnGroupRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.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/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/HeaderEncodeStrategy.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
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/toggler.js
Log:
start refactor for A2, remove vm logic from components, refactor component renderers, add
Sort, Expand event classes, dataScroller base render/ui. switcj off subTables expand
feature, prepare to remove togglerComponent
Modified:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/component/Expandable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/component/Expandable.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/component/Expandable.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -4,10 +4,10 @@
import org.richfaces.event.ToggleListener;
-//TODO nick - move to API
+//TODO: nick - move to API
public interface Expandable {
- //TODO nick - setExpanded()
+ //TODO: nick - setExpanded()
public boolean isExpanded();
public void addToggleListener(ToggleListener listener);
Added:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/PagingEvent.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/PagingEvent.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/PagingEvent.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,24 @@
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+public class PagingEvent extends FacesEvent {
+
+ public PagingEvent(UIComponent component) {
+ super(component);
+ }
+
+ private static final long serialVersionUID = -8176111805839316345L;
+
+ @Override
+ public boolean isAppropriateListener(FacesListener listener) {
+ return (listener instanceof PagingListener);
+ }
+
+ @Override
+ public void processListener(FacesListener listener) {
+ ((PagingListener) listener).processPaging(this);
+ }
+}
Added:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/PagingListener.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/PagingListener.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/PagingListener.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,9 @@
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+public interface PagingListener extends FacesListener {
+
+ public void processPaging(PagingEvent event);
+
+}
Added:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/SortingEvent.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/SortingEvent.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/SortingEvent.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,48 @@
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.swing.SortOrder;
+
+public class SortingEvent extends FacesEvent {
+
+ private static final long serialVersionUID = 2125258204996535522L;
+
+ private SortOrder sortOrder;
+
+ private String columnId;
+
+
+ public SortingEvent(UIComponent source, String columnId, SortOrder sortOrder) {
+ super(source);
+ this.sortOrder = sortOrder;
+ this.setColumnId(columnId);
+ }
+
+ @Override
+ public boolean isAppropriateListener(FacesListener listener) {
+ return (listener instanceof SortingListener);
+ }
+
+ @Override
+ public void processListener(FacesListener listener) {
+ ((SortingListener)listener).processSorting(this);
+ }
+
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+
+ public void setColumnId(String columnId) {
+ this.columnId = columnId;
+ }
+
+ public String getColumnId() {
+ return columnId;
+ }
+}
Added:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/SortingListener.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/SortingListener.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/SortingListener.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,9 @@
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+public interface SortingListener extends FacesListener {
+
+ public void processSorting(SortingEvent sortingEvent);
+
+}
Modified:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/ToggleListener.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/ToggleListener.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/event/ToggleListener.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -6,7 +6,6 @@
* @author Anton Belevich
*
*/
-//TODO nick - move to api
public interface ToggleListener extends FacesListener {
public void processToggle(ToggleEvent event);
Added:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Field.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Field.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Field.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,44 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import javax.el.Expression;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public abstract class Field {
+
+ private Expression expression;
+
+ public Field(Expression expression) {
+ this.expression = expression;
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+}
Added:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/SortField.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/SortField.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/SortField.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,22 @@
+package org.richfaces.model;
+
+import javax.el.Expression;
+import javax.swing.SortOrder;
+
+public class SortField extends Field {
+
+ private SortOrder sortOrder;
+
+ public SortField(SortOrder sortOrder, Expression expression) {
+ super(expression);
+ this.sortOrder = sortOrder;
+ }
+
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+}
Modified:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/visual/ColumnVisualModel.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/visual/ColumnVisualModel.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/visual/ColumnVisualModel.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,5 +1,7 @@
package org.richfaces.model.visual;
+import javax.el.ValueExpression;
+
import org.richfaces.model.Ordering;
/**
@@ -11,5 +13,10 @@
public void setSortOrdering(Ordering sortOrder);
public Ordering getSortOder();
+
+ public ValueExpression getSortBy();
+
+ public void setSortBy(ValueExpression sortBy);
+
}
Modified:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/visual/SortingFilteringVisualModel.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/visual/SortingFilteringVisualModel.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/visual/SortingFilteringVisualModel.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,17 +1,22 @@
package org.richfaces.model.visual;
import java.util.Collection;
-
+import org.richfaces.model.SortField;
import org.richfaces.model.SortMode;
public interface SortingFilteringVisualModel {
public SortMode getSortMode();
- public void setSortMode(SortMode sortMode);
-
- public Collection<String> getSortPriority();
-
- public void setSortPriority(Collection<String> sortPriority);
-
+ public void setSortMode(SortMode sortMode);
+
+ public void setSortPriority(Collection sortPriority);
+
+ public Collection getSortPriority();
+
+ public Collection <SortField> getSortFields();
+
+ public void addSortField(String id, SortField field);
+
+ public SortField getSortField(String id);
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -24,6 +24,8 @@
import javax.faces.component.UIComponent;
+import org.richfaces.component.Column;
+
/**
* Iterator for all children table columns.
*
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -24,6 +24,8 @@
import javax.faces.component.UIComponent;
+import org.richfaces.component.Column;
+
//TODO nick - rename to include component name
class DataIterator extends IteratorBase<UIComponent> {
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/FixedChildrenIterator.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/FixedChildrenIterator.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/FixedChildrenIterator.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -24,6 +24,7 @@
import javax.faces.component.UIComponent;
+
class FixedChildrenIterator extends DataIterator {
private Iterator<UIComponent> currentColumnIterator;
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/SubtableFixedChildrenIterator.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/SubtableFixedChildrenIterator.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/SubtableFixedChildrenIterator.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -22,6 +22,7 @@
import javax.faces.component.UIComponent;
+
/**
* @author asmirnov
*
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,77 +1,33 @@
package org.richfaces.component;
-import javax.el.MethodExpression;
+import javax.swing.SortOrder;
-import org.richfaces.model.Ordering;
public abstract class UIColumn extends javax.faces.component.UIColumn implements Column
{
- public abstract void setRowspan(int rowspan);
+ private SortOrder sortOrder;
+
public abstract int getRowspan();
- public abstract void setColspan(int colspan);
public abstract int getColspan();
- public abstract void setSortEvent(String sortEvent);
- public abstract String getSortEvent();
+ public abstract boolean isBreakBefore();
- //TODO: anton - add get/set sortIcon Asc/Desc/Unsort methods to the dataTable
- public abstract void setSortIconAsc(String sortIcon);
- public abstract String getSortIconAsc();
-
- public abstract void setSortIconDesc(String sortIcon);
- public abstract String getSortIconDesc();
-
- public abstract void setSortIconUnsort(String sortIcon);
- public abstract String getSortIconUnsort();
-
-
-
- /**
- * SortOrder is an enumeration of the possible sort orderings.
- *
- * @param sortOrder
- */
-
- //TODO nick - use annotation from Swing?
- //TODO anton - do you mean using javax.swing.SortOrder instead
org.richfaces.model.Orderinbg???
- public abstract void setSortOrder(Ordering sortOrder);
- public abstract Ordering getSortOrder();
-
- /**
- * expression used for column sorting.
- * literal value is treated as property of data object
- * EL-expression is evaluated on every data row
- * @param sortExpression
- */
- //TODO nick - use ValueExpression
- public abstract void setSortExpression(String sortExpression);
- public abstract String getSortExpression();
-
-
-
- //TODO nick - "filterExpression" is missing
-
- public abstract void setFilterMethod(MethodExpression methodExpression);
- public abstract MethodExpression getFilterMethod();
-
- //TODO nick - make this java.lang.Object. Use case: Long or Enum used as filtering
criteria
- public abstract void setFilterValue(String filterValue);
- public abstract String getFilterValue();
-
- public abstract void setSelfSorted(boolean selfSorted);
public abstract boolean isSelfSorted();
- /**
- * Out this column on new row
- * @parameter
- * @return the acceptClass
- */
- public abstract boolean isBreakBefore();
-
- /**
- * @param newBreakBefore the value to set
- */
- public abstract void setBreakBefore(boolean breakBefore);
+ public abstract void setSortOrder(SortOrder sortOrder);
+ public abstract SortOrder getSortOrder();
+
+
+ public SortOrder toggleSortOrder(){
+ if(SortOrder.ASCENDING.equals(getSortOrder())) {
+ sortOrder = SortOrder.DESCENDING;
+ } else {
+ sortOrder = SortOrder.ASCENDING;
+ }
+
+ return sortOrder;
+ }
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -34,12 +34,11 @@
* JSF component class
*
*/
-public abstract class UIColumnGroup extends UIPanel implements Row, Column {
- public static final String COMPONENT_TYPE = "org.richfaces.ColumnGroup";
- public static final String COMPONENT_FAMILY = "org.richfaces.ColumnGroup";
+public abstract class UIColumnGroup extends UIPanel implements Row, Column {
+
public Iterator<UIComponent> columns() {
return new ColumnsIterator(this);
}
@@ -60,10 +59,4 @@
//TODO nick - implement in the proper way
visitor.process(context, null, argument);
}
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataScroller.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataScroller.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataScroller.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,9 @@
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+public abstract class UIDataScroller extends UIComponentBase {
+
+ public abstract String getForId();
+
+}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,121 +1,41 @@
package org.richfaces.component;
-import java.util.Collection;
-
-import javax.el.ELContext;
-import javax.el.ValueExpression;
+import javax.el.MethodExpression;
import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
import org.ajax4jsf.model.DataComponentState;
import org.richfaces.component.state.DataTableState;
-import org.richfaces.model.SortMode;
-import org.richfaces.model.visual.DataTableVisualModel;
-import org.richfaces.model.visual.SortingFilteringVisualModel;
-import org.richfaces.model.visual.impl.DataTableVisualModelImpl;
-import org.richfaces.model.visual.impl.SortingFilteringVisualModelImpl;
+import org.richfaces.event.SortingEvent;
/**
* @author Anton Belevich
*
*/
+
public abstract class UIDataTable extends UIDataTableBase {
- private DataTableVisualModel visualModel;
-
- private SortMode sortMode;
-
- private Collection<String> sortPriority;
-
enum PropertyKeys {
- sortingFilteringVisualModel
+ sortingExpression
}
- public void setVisualModel(DataTableVisualModel visualModel) {
- this.visualModel = visualModel;
+ public void setSortingListener(MethodExpression sortingExpression) {
+ //TODO nick - use addToggleListener() & MethodExpression wrapper in tag
+ getStateHelper().put(PropertyKeys.sortingExpression, sortingExpression);
}
+
+ public MethodExpression getSortingListener() {
+ return (MethodExpression) getStateHelper().eval(PropertyKeys.sortingExpression);
+ }
public DataTableState getCurrentComponentState() {
return (DataTableState) getComponentState();
}
- public void setSortingFilteringVisualModel(SortingFilteringVisualModel
sortingFilteringVisualModel){
- getStateHelper().put(PropertyKeys.sortingFilteringVisualModel,
sortingFilteringVisualModel);
- }
-
- public SortingFilteringVisualModel getSortingFilteringVisualModel(){
- return
(SortingFilteringVisualModel)getStateHelper().eval(PropertyKeys.sortingFilteringVisualModel);
- }
-
- public DataTableVisualModel getVisualModel() {
-
- DataTableState dataTableState = getCurrentComponentState();
- DataTableVisualModel model = dataTableState.getVisualModel();
-
- if(model == null) {
-
- if(visualModel == null) {
-
- ELContext elContext = getFacesContext().getELContext();
- ValueExpression modelExpression =
getValueExpression("visualModel");
-
- if(modelExpression != null) {
- model = (DataTableVisualModel) modelExpression.getValue(elContext);
- }
-
- if(model == null) {
- model = new DataTableVisualModelImpl();
-
- if ((modelExpression != null) &&
(!modelExpression.isReadOnly(elContext))) {
- //TODO nick - handle ELException
- modelExpression.setValue(elContext, model);
- }
- }
-
- } else {
- model = visualModel;
- }
-
- if(model.getSortingFilteringVisualModel() == null) {
- model.setSortingFilteringVisualModel(initSortingFilteringVisualModel());
- } else {
- //TODO nick - init SortingFilteringVisualModel from model
- }
- }
-
- dataTableState.setVisualModel(model);
-
- return model;
- }
-
- protected SortingFilteringVisualModel initSortingFilteringVisualModel() {
- SortingFilteringVisualModel sortingFilteringVisualModel =
getSortingFilteringVisualModel();
- if(sortingFilteringVisualModel == null) {
- sortingFilteringVisualModel = new SortingFilteringVisualModelImpl();
- }
-
- sortingFilteringVisualModel.setSortMode(sortMode);
- sortingFilteringVisualModel.setSortPriority(sortPriority);
-
- return sortingFilteringVisualModel;
- }
-
- public void setSortMode(SortMode sortMode) {
- this.sortMode = sortMode;
- }
-
- public SortMode getSortMode() {
- return getVisualModel().getSortingFilteringVisualModel().getSortMode();
- }
-
- public void setSortPriority(Collection<String> sortPriority){
- this.sortPriority = sortPriority;
- }
-
- public Collection<String> getSortPriority() {
- return getVisualModel().getSortingFilteringVisualModel().getSortPriority();
- }
-
@Override
protected DataComponentState createComponentState() {
return new DataTableState(getFirst(), getRows());
@@ -125,79 +45,40 @@
return getFacet("caption");
}
- //TODO nick - move methods that work with CSS classes into renderer
- public String getTableSkinClass() {
- return "rich-table";
- }
-
- public String getCaptionSkinClass() {
- return "rich-table-caption";
- }
-
@Override
- public String getFirstRowSkinClass() {
- return "rich-table-first-row";
- }
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+ if(event instanceof SortingEvent) {
+ SortingEvent sortingEvent = (SortingEvent)event;
+
+ DataTableState state = getCurrentComponentState();
+ if(event.isAppropriateListener(state)) {
+ sortingEvent.processListener(state);
+ }
+
+ MethodExpression expression = getSortingListener();
+ FacesContext context = getFacesContext();
- @Override
- public String getRowSkinClass() {
- return "rich-table-row";
+ if (expression != null) {
+ expression.invoke(context.getELContext(), new Object[] { sortingEvent
});
+ }
+
+ }
}
- public String getCellSkinClass() {
- return "rich-table-cell";
- }
-
- public String getHeaderSkinClass() {
- return "rich-table-header";
- }
-
+
@Override
- public String getHeaderFirstSkinClass() {
- return "rich-table-header-first";
+ public void queueEvent(FacesEvent event) {
+ if(event instanceof SortingEvent) {
+ //TODO immediate ???
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ super.queueEvent(event);
+
}
- public String getHeaderCellSkinClass() {
- return "rich-table-header-cell";
- }
+ public String[] getHiddenInputId() {
+ return (new String[]{getClientId()+ ":sort"});
+ }
- public String getColumnHeaderSkinClass() {
- return "rich-table-subheader";
- }
-
- @Override
- public String getColumnHeaderFirstSkinClass() {
- return "rich-table-subheader-first";
- }
-
- public String getColumnHeaderCellSkinClass() {
- return "rich-table-subheader-cell";
- }
-
- public String getColumnFooterSkinClass() {
- return "rich-table-subfooter";
- }
-
- @Override
- public String getColumnFooterFirstSkinClass() {
- return "rich-table-subfooter-first";
- }
-
- public String getColumnFooterCellSkinClass() {
- return "rich-table-subfooter-cell";
- }
-
- public String getFooterSkinClass() {
- return "rich-table-footer";
- }
-
- @Override
- public String getFooterFirstSkinClass() {
- return "rich-table-footer-first";
- }
-
- public String getFooterCellSkinClass() {
- return "rich-table-footer-cell";
- }
-
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,5 +1,6 @@
package org.richfaces.component;
+import java.util.Collection;
import java.util.Iterator;
import javax.faces.component.UIComponent;
@@ -29,7 +30,7 @@
public UIComponent getFooter() {
return getFacet("footer");
}
-
+
@Override
public boolean getRendersChildren() {
return true;
@@ -38,37 +39,10 @@
public abstract SortMode getSortMode();
public abstract void setSortMode(SortMode sortMode);
-
- public abstract String getTableSkinClass();
- public abstract String getFirstRowSkinClass();
-
- public abstract String getRowSkinClass();
-
- public abstract String getHeaderCellSkinClass();
-
- public abstract String getHeaderSkinClass();
-
- public abstract String getHeaderFirstSkinClass();
+ public abstract Collection <Object> getSortPriority();
- public abstract String getColumnHeaderCellSkinClass();
-
- public abstract String getColumnHeaderSkinClass();
+ public abstract void setSortPriority(Collection<Object> sortPriority);
- public abstract String getColumnHeaderFirstSkinClass();
- public abstract String getFooterCellSkinClass();
-
- public abstract String getFooterSkinClass();
-
- public abstract String getFooterFirstSkinClass();
-
- public abstract String getColumnFooterCellSkinClass();
-
- public abstract String getColumnFooterSkinClass();
-
- public abstract String getColumnFooterFirstSkinClass();
-
- public abstract String getCellSkinClass();
-
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -21,9 +21,7 @@
package org.richfaces.component;
-import javax.el.ELContext;
import javax.el.MethodExpression;
-import javax.el.ValueExpression;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
@@ -35,73 +33,24 @@
import org.richfaces.component.state.SubTableState;
import org.richfaces.event.ToggleEvent;
import org.richfaces.event.ToggleListener;
-import org.richfaces.model.visual.SubTableVisualModel;
-import org.richfaces.model.visual.impl.SubTableVisualModelImpl;
/**
* JSF component class
*
*/
+
public abstract class UISubTable extends UIDataTableBase implements Row, Column,
Expandable {
- public static final String COMPONENT_TYPE = "org.richfaces.SubTable";
-
- public static final String COMPONENT_FAMILY = "org.richfaces.SubTable";
-
public static final String SWITCH_TYPE_SERVER = "server";
- public static final String SWITCH_TYPE_CLIENT = "client";
-
public static final String SWITCH_TYPE_AJAX = "ajax";
- private boolean expanded;
-
- private SubTableVisualModel visualModel;
-
- // private SubTableState componentState;
-
+
enum PropertyKeys {
- switchType, expanded, toggleExpression, childState, visualModel
+ switchType, expanded, toggleExpression
}
- public SubTableVisualModel getVisualModel() {
- // TODO refactor
-
- SubTableVisualModel model = getCurrentComponentState().getCurrentRowModel();
-
- if (model == null) {
-
- if (visualModel == null) {
-
- ELContext elContext = getFacesContext().getELContext();
- ValueExpression modelExpression =
getValueExpression("visualModel");
- if (modelExpression != null) {
- model = (SubTableVisualModel) modelExpression.getValue(elContext);
- }
-
- if (model == null) {
- model = new SubTableVisualModelImpl();
- model.setExpanded(expanded);
-
- if ((modelExpression != null) &&
(!modelExpression.isReadOnly(elContext))) {
- modelExpression.setValue(elContext, model);
- }
- }
- } else {
- model = visualModel;
- }
-
- getCurrentComponentState().setCurrentRowModel(model);
- }
-
- return model;
- }
-
- public void setVisualModel(SubTableVisualModel visualModel) {
- this.visualModel = visualModel;
- }
-
public boolean isBreakBefore() {
return true;
}
@@ -176,14 +125,10 @@
return state;
}
- public void setExpanded(boolean expanded) {
- this.expanded = expanded;
- }
+ public abstract void setExpanded(boolean expanded);
- public boolean isExpanded() {
- return getVisualModel().isExpanded();
- }
-
+ public abstract boolean isExpanded();
+
public void setToggleListener(MethodExpression toggleExpression) {
//TODO nick - use addToggleListener() & MethodExpression wrapper in tag
getStateHelper().put(PropertyKeys.toggleExpression, toggleExpression);
@@ -197,13 +142,8 @@
public void queueEvent(FacesEvent event) {
//TODO nick - what if event comes from the nested subTable?
if (event instanceof ToggleEvent) {
- //TODO nick - why Ajax is processing at special phase?
//TODO nick - "immediate" support?
- if(getSwichType().equals(SWITCH_TYPE_AJAX)) {
- event.setPhaseId(PhaseId.INVOKE_APPLICATION);
- } else {
- event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
- }
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
}
super.queueEvent(event);
}
@@ -233,7 +173,7 @@
toggle.addRenderId(getClientId(context));
}
}
-
+
public void addToggleListener(ToggleListener listener) {
addFacesListener(listener);
}
@@ -245,104 +185,6 @@
public ToggleListener[] getToggleListeners() {
return (ToggleListener[]) getFacesListeners(ToggleListener.class);
}
-
- @Override
- public boolean getRendersChildren() {
- return true;
- }
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
- //TODO nick - these methods are renderer-specific, should be moved to
renderer-related code
- @Override
- public String getRowSkinClass() {
- return "rich-subtable-row";
- }
-
- @Override
- public String getFirstRowSkinClass() {
- return "rich-subtable-first-row";
- }
-
- public String getHeaderRowSkinClass() {
- return "rich-subtable-header-row";
- }
-
- public String getHeaderFirstRowSkinClass() {
- return "rich-subtable-header-first";
- }
-
- public String getCellSkinClass() {
- return "rich-subtable-cell";
- }
-
- public String getHeaderCellSkinClass() {
- return "rich-subtable-header-cell";
- }
-
-
- public String getColumnHeaderCellSkinClass() {
- return "rich-subtable-subheader-cell";
- }
-
- public String getColumnHeaderSkinClass() {
- return "rich-subtable-subheader";
- }
-
- public String getFooterCellSkinClass() {
- return "rich-subtable-footer-cell";
- }
-
- public String getFooterSkinClass() {
- return "rich-subtable-footer";
- }
-
- public String getFooterFirstRowSkinClass() {
- return "rich-subtable-footer-first";
- }
-
- public String getColumnFooterCellSkinClass() {
- return "rich-subtable-subfooter-cell";
- }
-
- public String getColumnFooterSkinClass() {
- return "rich-subtable-subfooter-cell";
- }
-
- public String getTableSkinClass() {
- return null;
- }
-
- public String getTableHeadSkinClass() {
- return null;
- }
-
- @Override
- public String getColumnFooterFirstSkinClass() {
- return "rich-subtable-subfooter-first"; }
-
- @Override
- public String getColumnHeaderFirstSkinClass() {
- return "rich-subtable-subheader-first";
- }
-
- @Override
- public String getFooterFirstSkinClass() {
- return "rich-subtable-footer-first";
- }
-
- @Override
- public String getHeaderFirstSkinClass() {
- return "rich-subtable-header-first";
- }
-
- @Override
- public String getHeaderSkinClass() {
- return "rich-subtable-header";
- }
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/behavior/ToggleBehavior.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/behavior/ToggleBehavior.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/behavior/ToggleBehavior.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,50 @@
+package org.richfaces.component.behavior;
+
+import javax.faces.component.behavior.ClientBehaviorBase;
+import javax.faces.component.behavior.FacesBehavior;
+
+
+//TODO: anton need implement base class for our behaviors
+(a)FacesBehavior(value="org.richfaces.behavior.ToggleBehavior")
+public class ToggleBehavior extends ClientBehaviorBase {
+
+ public static final String BEHAVIOR_ID =
"org.richfaces.behavior.ToggleBehavior";
+
+ private String toggleEvent;
+
+ private String toggleComponent;
+
+ private String toggleSource;
+
+
+ public String getToggleSource() {
+ return toggleSource;
+ }
+
+ public void setToggleSource(String toogleSource) {
+ this.toggleSource = toogleSource;
+ }
+
+ public String getToggleEvent() {
+ //TODO: anton - eval valueExpression
+ return toggleEvent;
+ }
+
+ public String getToggleComponentId() {
+ //TODO: anton - eval valueExpression
+ return toggleComponent;
+ }
+
+ public void setToggleComponent(String toggleComponent) {
+ this.toggleComponent = toggleComponent;
+ }
+
+ public void setToggleEvent(String toggleEvent) {
+ this.toggleEvent = toggleEvent;
+ }
+
+ @Override
+ public String getRendererType() {
+ return BEHAVIOR_ID;
+ }
+}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,31 +1,22 @@
package org.richfaces.component.html;
-import javax.el.MethodExpression;
+import javax.swing.SortOrder;
import org.richfaces.component.UIColumn;
-import org.richfaces.model.Ordering;
public class HtmlColumn extends UIColumn {
enum PropertyKeys {
- breakBefore, rowspan, colspan, sortEvent, sortOrder, selfSorted, sortBy,
sortIconAsc, sortIconDesc, sortIconUnsort
+ breakBefore, rowspan, colspan, sortOrder, selfSorted, sortBy
}
public static final String COMPONENT_TYPE = "org.richfaces.Column";
+
public static final String COMPONENT_FAMILY = "org.richfaces.Column";
- public void setBreakBefore(boolean breakBefore) {
- getStateHelper().put(PropertyKeys.breakBefore, Boolean.valueOf(breakBefore));
- }
-
- public boolean isBreakBefore() {
- Boolean breakBefore = ((Boolean) getStateHelper().eval(PropertyKeys.breakBefore,
Boolean.FALSE));
- return breakBefore.booleanValue();
- }
-
+
public int getColspan() {
- Integer colspan = (Integer) getStateHelper().eval(PropertyKeys.colspan,
Integer.MIN_VALUE);
- return colspan.intValue();
+ return (Integer) getStateHelper().eval(PropertyKeys.colspan,
Integer.MIN_VALUE);
}
public void setColspan(int colspan) {
@@ -33,8 +24,7 @@
}
public int getRowspan() {
- Integer rowspan = (Integer) getStateHelper().eval(PropertyKeys.rowspan,
Integer.MIN_VALUE);
- return rowspan.intValue();
+ return (Integer) getStateHelper().eval(PropertyKeys.rowspan, Integer.MIN_VALUE);
}
public void setRowspan(int rowspan) {
@@ -42,41 +32,15 @@
}
@Override
- public String getSortEvent() {
- //TODO: anton - pass correct event name to the client ...
- return (String)getStateHelper().eval(PropertyKeys.sortEvent, "click");
+ public SortOrder getSortOrder() {
+ return (SortOrder)
getStateHelper().eval(PropertyKeys.sortOrder,SortOrder.DESCENDING);
}
-
+
@Override
- public Ordering getSortOrder() {
- return (Ordering)
getStateHelper().eval(PropertyKeys.sortOrder,Ordering.DESCENDING);
+ public void setSortOrder(SortOrder sortOrder) {
+ getStateHelper().put(PropertyKeys.sortOrder, sortOrder);
}
- @Override
- public void setSortEvent(String sortEvent) {
- getStateHelper().put(PropertyKeys.sortEvent, sortEvent);
- }
-
- @Override
- public void setSortOrder(Ordering sortOrder) {
- getStateHelper().put(PropertyKeys.sortOrder, sortOrder);
- }
-
- public MethodExpression getFilterMethod() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getFilterValue() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getSortExpression() {
- // TODO Auto-generated method stub
- return null;
- }
-
public boolean isSelfSorted() {
return (Boolean)getStateHelper().eval(PropertyKeys.selfSorted, true);
}
@@ -85,32 +49,6 @@
getStateHelper().put(PropertyKeys.selfSorted, selfSorted);
}
-
- public boolean isSortable() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void setFilterMethod(MethodExpression methodExpression) {
- // TODO Auto-generated method stub
-
- }
-
- public void setFilterValue(String filterValue) {
- // TODO Auto-generated method stub
-
- }
-
- public void setSortExpression(String sortExpression) {
- // TODO Auto-generated method stub
-
- }
-
- public void setSortable(boolean sortable) {
- // TODO Auto-generated method stub
-
- }
-
public Object getSortBy() {
return getStateHelper().eval(PropertyKeys.sortBy);
}
@@ -120,33 +58,11 @@
}
@Override
- public String getSortIconAsc() {
- return (String)getStateHelper().get(PropertyKeys.sortIconAsc);
+ public boolean isBreakBefore() {
+ return (Boolean)getStateHelper().eval(PropertyKeys.breakBefore, false);
}
-
- @Override
- public String getSortIconDesc() {
- return (String)getStateHelper().get(PropertyKeys.sortIconDesc);
+
+ public void setBreakBefore(boolean breakBefore) {
+ getStateHelper().put(PropertyKeys.breakBefore, breakBefore);
}
-
- @Override
- public String getSortIconUnsort() {
- return (String)getStateHelper().get(PropertyKeys.sortIconUnsort);
- }
-
- @Override
- public void setSortIconAsc(String sortIcon) {
- getStateHelper().put(PropertyKeys.sortIconAsc, sortIcon);
- }
-
- @Override
- public void setSortIconDesc(String sortIcon) {
- getStateHelper().put(PropertyKeys.sortIconDesc, sortIcon);
- }
-
- @Override
- public void setSortIconUnsort(String sortIcon) {
- getStateHelper().put(PropertyKeys.sortIconUnsort, sortIcon);
- }
-
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -3,7 +3,11 @@
import org.richfaces.component.UIColumnGroup;
public class HtmlColumnGroup extends UIColumnGroup {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.ColumnGroup";
+ public static final String COMPONENT_FAMILY = "org.richfaces.Column";
+
@Override
public String getFamily() {
return COMPONENT_FAMILY;
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlDataTable.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlDataTable.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,19 +1,40 @@
package org.richfaces.component.html;
+import java.util.Collection;
+
import org.richfaces.component.UIDataTable;
+import org.richfaces.model.SortMode;
public class HtmlDataTable extends UIDataTable {
public static final String COMPONENT_TYPE = "org.richfaces.DataTable";
- public static final String COMPONENT_FAMILY = "org.richfaces.DataTable";
-
+
+ protected enum PropertyKeys {
+ sortMode, sortPriority,
+ }
+
public HtmlDataTable() {
setRendererType("org.richfaces.DataTableRenderer");
}
@Override
- public String getFamily() {
- return COMPONENT_FAMILY;
+ public SortMode getSortMode() {
+ return (SortMode)getStateHelper().eval(PropertyKeys.sortMode, SortMode.single);
}
-}
+
+ @Override
+ public Collection<Object> getSortPriority() {
+ return (Collection)getStateHelper().eval(PropertyKeys.sortPriority);
+ }
+
+ @Override
+ public void setSortMode(SortMode sortMode) {
+ getStateHelper().put(PropertyKeys.sortMode, sortMode);
+ }
+
+ @Override
+ public void setSortPriority(Collection<Object> sortPriority) {
+ getStateHelper().put(PropertyKeys.sortPriority, sortPriority);
+ }
+ }
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlExtendedDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlExtendedDataTable.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlExtendedDataTable.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -21,7 +21,10 @@
*/
package org.richfaces.component.html;
+import java.util.Collection;
+
import org.richfaces.component.UIExtendedDataTable;
+import org.richfaces.model.SortMode;
public class HtmlExtendedDataTable extends UIExtendedDataTable {
@@ -58,13 +61,23 @@
public void setFrozenColumns(Integer frozenColumns) {
getStateHelper().put(PropertyKeys.frozenColumns, frozenColumns);
}
- //
- // public String getHeight() {
- // return (String) getStateHelper().eval(PropertyKeys.height, "");
- // }
- //
- // public void setHeight(String height) {
- // getStateHelper().put(PropertyKeys.height, height);
- // }
+ @Override
+ public SortMode getSortMode() {
+ return null;
+ }
+
+ @Override
+ public Collection<Object> getSortPriority() {
+ return null;
+ }
+
+ @Override
+ public void setSortMode(SortMode sortMode) {
+ }
+
+ @Override
+ public void setSortPriority(Collection<Object> sortPriority) {
+ }
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSubTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSubTable.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSubTable.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,25 +1,47 @@
package org.richfaces.component.html;
+import java.util.Collection;
+
import org.richfaces.component.UISubTable;
import org.richfaces.model.SortMode;
public class HtmlSubTable extends UISubTable {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.SubTable";
+
+
+ protected enum PropertyKeys {
+ expand, sortMode, sortPriority
+ }
+
@Override
- public String getFamily() {
- return COMPONENT_FAMILY;
+ public boolean isExpanded() {
+ return (Boolean)getStateHelper().eval(PropertyKeys.expand, false);
}
@Override
+ public void setExpanded(boolean expanded) {
+ getStateHelper().put(PropertyKeys.expand, expanded);
+ }
+
+ @Override
public SortMode getSortMode() {
- // TODO Auto-generated method stub
- return null;
+ return (SortMode)getStateHelper().eval(PropertyKeys.sortMode, SortMode.single);
}
@Override
+ public Collection<Object> getSortPriority() {
+ return (Collection)getStateHelper().eval(PropertyKeys.sortPriority);
+ }
+
+ @Override
public void setSortMode(SortMode sortMode) {
- // TODO Auto-generated method stub
-
+ getStateHelper().put(PropertyKeys.sortMode, sortMode);
}
+ @Override
+ public void setSortPriority(Collection<Object> sortPriority) {
+ getStateHelper().put(PropertyKeys.sortPriority, sortPriority);
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/DataTableState.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/DataTableState.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/DataTableState.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -8,16 +8,15 @@
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.RepeatState;
-import org.richfaces.model.visual.DataTableVisualModel;
+import org.richfaces.event.SortingEvent;
+import org.richfaces.event.SortingListener;
/**
* @author Anton Belevich
*
*/
-public class DataTableState extends RepeatState implements StateHolder {
+public class DataTableState extends RepeatState implements StateHolder, SortingListener
{
- private DataTableVisualModel visualModel;
-
private Map<String, SubTableState> subTableStates = new HashMap<String,
SubTableState>();
private int first;
@@ -29,14 +28,6 @@
this.rows = rows;
}
- public void setVisualModel(DataTableVisualModel visualModel) {
- this.visualModel = visualModel;
- }
-
- public DataTableVisualModel getVisualModel() {
- return this.visualModel;
- }
-
@Override
public int getFirst() {
return this.first;
@@ -87,4 +78,7 @@
DataComponentState state = getSubTableState(id);
return state;
}
+
+ public void processSorting(SortingEvent sortingEvent) {
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/SubTableState.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/SubTableState.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/SubTableState.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -6,7 +6,6 @@
import org.ajax4jsf.model.RepeatState;
import org.richfaces.event.ToggleEvent;
import org.richfaces.event.ToggleListener;
-import org.richfaces.model.visual.SubTableVisualModel;
/**
* @author Anton Belevich
@@ -14,8 +13,6 @@
*/
public class SubTableState extends RepeatState implements StateHolder, ToggleListener {
- private SubTableVisualModel model;
-
private String id;
private int first;
@@ -46,24 +43,6 @@
return this.rows;
}
- public SubTableVisualModel getCurrentRowModel() {
- return this.model;
- }
-
- public void setCurrentRowModel(SubTableVisualModel model) {
- this.model = model;
- }
-
- //TODO nick - do we need to support SubTableVisualModel that are StateHolder?
- public void restoreState(FacesContext context, Object state) {
- Object[] currentState = (Object[]) state;
- this.model = (SubTableVisualModel) currentState[0];
- }
-
- public Object saveState(FacesContext context) {
- return new Object[] { this.model };
- }
-
public boolean isTransient() {
return false;
}
@@ -72,7 +51,15 @@
}
public void processToggle(ToggleEvent event) {
- boolean newValue = event.isExpanded();
- this.model.setExpanded(newValue);
}
+
+ @Override
+ public void restoreState(FacesContext arg0, Object arg1) {
+ }
+
+ @Override
+ public Object saveState(FacesContext arg0) {
+ return null;
+ }
+
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/facelets/tag/ToggleHandler.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/facelets/tag/ToggleHandler.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/facelets/tag/ToggleHandler.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,12 @@
+package org.richfaces.facelets.tag;
+
+import javax.faces.view.facelets.BehaviorConfig;
+import javax.faces.view.facelets.BehaviorHandler;
+
+public class ToggleHandler extends BehaviorHandler {
+
+ public ToggleHandler(BehaviorConfig config) {
+ super(config);
+ }
+
+}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/ColumnVisualModelImpl.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/ColumnVisualModelImpl.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/ColumnVisualModelImpl.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,5 +1,7 @@
package org.richfaces.model.visual.impl;
+import javax.el.ValueExpression;
+
import org.richfaces.model.Ordering;
import org.richfaces.model.visual.ColumnVisualModel;
@@ -10,6 +12,10 @@
public class ColumnVisualModelImpl implements ColumnVisualModel {
private Ordering sortOrder;
+
+ private ValueExpression sortBy;
+
+ private ValueExpression comparator;
public ColumnVisualModelImpl() {
}
@@ -21,4 +27,17 @@
public void setSortOrdering(Ordering sortOrder) {
this.sortOrder = sortOrder;
}
+
+ public ValueExpression getSortBy() {
+ return sortBy;
+ }
+
+ public ValueExpression getComparator() {
+ return comparator;
+ }
+
+ public void setSortBy(ValueExpression sortBy) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/SortingFilteringVisualModelImpl.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/SortingFilteringVisualModelImpl.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/SortingFilteringVisualModelImpl.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,30 +1,51 @@
package org.richfaces.model.visual.impl;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.LinkedHashMap;
+import org.richfaces.model.SortField;
import org.richfaces.model.SortMode;
import org.richfaces.model.visual.SortingFilteringVisualModel;
+/**
+ * @author Anton Belevich
+ *
+ */
public class SortingFilteringVisualModelImpl implements SortingFilteringVisualModel {
private SortMode sortMode;
- private Collection<String> sortPriority;
+ private LinkedHashMap<String, SortField> sortFields = new
LinkedHashMap<String, SortField>();
- public SortMode getSortMode() {
- return sortMode;
+ private Collection<Object> sortPriority = new ArrayList<Object>();
+
+ public void addSortField(String id, SortField sortField) {
+ sortFields.put(id, sortField);
}
- public Collection<String> getSortPriority() {
- return sortPriority;
+ public Collection<SortField> getSortFields() {
+ return sortFields.values();
}
+ public SortMode getSortMode() {
+ return this.sortMode;
+ }
+
public void setSortMode(SortMode sortMode) {
this.sortMode = sortMode;
}
- public void setSortPriority(Collection<String> sortPriority) {
+ public SortField getSortField(String id) {
+ return sortFields.get(id);
+ }
+
+ public Collection<Object> getSortPriority() {
+ return sortPriority;
+ }
+
+ public void setSortPriority(Collection sortPriority) {
this.sortPriority = sortPriority;
}
-
}
+
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-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -11,13 +11,12 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.Column;
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.UISubTable;
@ResourceDependencies(value = { @ResourceDependency(library = "javax.faces",
name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"), @ResourceDependency(name =
"richfaces.js") })
+ @ResourceDependency(name = "jquery.js"), @ResourceDependency(name =
"richfaces.js"), @ResourceDependency(name = "richfaces-event.js")})
public abstract class AbstractTableRenderer extends DataTableRowsRenderer {
public static final String ROW_CLASS = "rowClass";
@@ -26,6 +25,7 @@
public static final String CELL_CLASS = "cellClass";
+ public static final String SORTING = "sorting";
public boolean isColumnFacetPresent(UIDataTableBase table, String facetName) {
Iterator<UIComponent> columns = table.columns();
@@ -140,9 +140,9 @@
dataTable.setRowKey(context, key);
dataTable.restoreOrigValue(context);
- String rowClass = dataTable.getRowSkinClass();
- String cellClass = dataTable.getCellSkinClass();
- String firstClass = dataTable.getFirstRowSkinClass();
+ String rowClass = getRowSkinClass();
+ String cellClass = getCellSkinClass();
+ String firstClass = getFirstRowSkinClass();
rowClass = mergeStyleClasses("rowClass", rowClass, dataTable);
cellClass = mergeStyleClasses("cellClass", cellClass, dataTable);
@@ -162,15 +162,27 @@
public void encodeTableStart(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException {
writer.startElement(HTML.TABLE_ELEMENT, component);
- String styleClass = component.getTableSkinClass();
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, component.getClientId(), null);
+ String styleClass = getTableSkinClass();
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
}
public void encodeTableEnd(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException {
writer.endElement(HTML.TABLE_ELEMENT);
encodeClientScript(writer, context, component);
+ encodeSortHiddenInput(writer, context, component);
}
+ 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)
@@ -213,9 +225,9 @@
if (columnFacetPresent) {
- String rowClass = dataTable.getColumnFooterSkinClass();
- String cellClass = dataTable.getColumnFooterCellSkinClass();
- String firstClass = dataTable.getColumnFooterFirstSkinClass();
+ String rowClass = getColumnFooterSkinClass();
+ String cellClass = getColumnFooterCellSkinClass();
+ String firstClass = getColumnFooterFirstSkinClass();
rowClass = mergeStyleClasses("columnFooterClass", rowClass,
dataTable);
cellClass = mergeStyleClasses("columnFooterCellClass",
cellClass, dataTable);
@@ -231,9 +243,9 @@
if (footer != null && footer.isRendered()) {
- String rowClass = dataTable.getFooterSkinClass();
- String cellClass = dataTable.getFooterCellSkinClass();
- String firstClass = dataTable.getFooterFirstSkinClass();
+ String rowClass = getFooterSkinClass();
+ String cellClass = getFooterCellSkinClass();
+ String firstClass = getFooterFirstSkinClass();
rowClass = mergeStyleClasses("footerClass", rowClass,
dataTable);
cellClass = mergeStyleClasses("footerCellClass", cellClass,
dataTable);
@@ -285,9 +297,9 @@
if (header != null && header.isRendered()) {
- String rowClass = dataTable.getHeaderSkinClass();
- String cellClass = dataTable.getHeaderCellSkinClass();
- String firstClass = dataTable.getHeaderFirstSkinClass();
+ String rowClass = getHeaderSkinClass();
+ String cellClass = getHeaderCellSkinClass();
+ String firstClass = getHeaderFirstSkinClass();
rowClass = mergeStyleClasses("headerClass", rowClass,
dataTable);
cellClass = mergeStyleClasses("headerCellClass", cellClass,
dataTable);
@@ -299,9 +311,9 @@
if (isEncodeHeaders) {
- String rowClass = dataTable.getColumnHeaderSkinClass();
- String cellClass = dataTable.getColumnHeaderCellSkinClass();
- String firstClass = dataTable.getColumnHeaderFirstSkinClass();
+ String rowClass = getColumnHeaderSkinClass();
+ String cellClass = getColumnHeaderCellSkinClass();
+ String firstClass = getColumnHeaderFirstSkinClass();
rowClass = mergeStyleClasses("columnHeaderClass", rowClass,
dataTable);
cellClass = mergeStyleClasses("columnHeaderCellClass",
cellClass, dataTable);
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -46,5 +46,101 @@
return new RowHolder(context,
parent.getClientId(context),(UIColumnGroup)component);
}
+
+ @Override
+ public String getCellSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnFooterCellSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnFooterFirstSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnFooterSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnHeaderCellSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnHeaderFirstSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnHeaderSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getFirstRowSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getFooterCellSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getFooterFirstSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getFooterSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getHeaderCellSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getHeaderFirstSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getHeaderSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRowSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getTableSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataScrollerRenderBase.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataScrollerRenderBase.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataScrollerRenderBase.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,28 @@
+package org.richfaces.renderkit;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.RendererBase;
+import org.richfaces.component.UIDataScroller;
+import org.richfaces.component.UISubTable;
+
+public class DataScrollerRenderBase extends RendererBase{
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+
+ }
+
+ protected UISubTable findComponent(FacesContext context, UIDataScroller ds) {
+ String forId = ds.getForId();
+
+ if (forId != null && forId.length() > 0) {
+ UIComponent subTable = getUtils().findComponentFor(context, ds, forId);
+ if (subTable instanceof UISubTable) {
+ return (UISubTable) subTable;
+ }
+ }
+ return null;
+ }
+}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -1,8 +1,10 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
@@ -10,6 +12,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.swing.SortOrder;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
@@ -17,17 +20,57 @@
import org.richfaces.component.UIDataTable;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.UISubTable;
-import org.richfaces.component.util.FormUtil;
+import org.richfaces.event.SortingEvent;
import org.richfaces.model.Ordering;
+import org.richfaces.model.SortMode;
@ResourceDependencies( { @ResourceDependency(library = "javax.faces", name =
"jsf-uncompressed.js"),
@ResourceDependency(name = "jquery.js"), @ResourceDependency(name =
"richfaces.js"),
- @ResourceDependency(name = "datatable.js"), @ResourceDependency(name =
"table.css") })
+ @ResourceDependency(name= "richfaces-event.js"), @ResourceDependency(name =
"datatable-test.js"),
+ @ResourceDependency(name = "table.css") })
public class DataTableRenderer extends AbstractTableRenderer {
+
@Override
protected void doDecode(FacesContext context, UIComponent component) {
- System.out.println("DataTableRenderer.doDecode()");
+ Map<String, String> requestMap =
context.getExternalContext().getRequestParameterMap();
+
+ //decode column
+
+ UIDataTable dataTable = (UIDataTable)component;
+
+ String sortColumn = requestMap.get(dataTable.getClientId()+":sort");
+
+ if(sortColumn != null && sortColumn.trim().length() > 0) {
+ Collection<Object> sortPriority = dataTable.getSortPriority();
+
+ boolean isSingle = SortMode.single.equals(dataTable.getSortMode());
+
+ if(isSingle) {
+ //reset saved sort priorities
+ sortPriority.clear();
+ }
+
+ Iterator<UIComponent> columns = dataTable.columns();
+ while(columns.hasNext()) {
+
+ UIComponent column = columns.next();
+
+ if(column instanceof org.richfaces.component.UIColumn &&
isSortable((org.richfaces.component.UIColumn)column)) {
+
+ org.richfaces.component.UIColumn sortableColumn =
(org.richfaces.component.UIColumn)column;
+
+ if(sortableColumn.getClientId().equals(sortColumn)) {
+ SortOrder newSortOrder = sortableColumn.toggleSortOrder();
+ new SortingEvent(dataTable, column.getClientId(context),
newSortOrder).queue();
+ sortPriority.add(sortColumn);
+ } else if(isSingle) {
+ sortableColumn.setSortOrder(SortOrder.UNSORTED);
+ }
+
+ }
+ }
+ }
}
public void encodeTableStructure(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable)
@@ -54,9 +97,9 @@
writer.endElement("colgroup");
}
-
}
+
@Override
public RowHolder createRowHolder(FacesContext context, UIComponent component) {
return new RowHolder(context, (UIDataTable)component);
@@ -142,7 +185,7 @@
writer.startElement(HTML.CAPTION_ELEMENT, dataTable);
String captionClass = (String)
dataTable.getAttributes().get("captionClass");
- String captionSkinClass = dataTable.getCaptionSkinClass();
+ String captionSkinClass = getCaptionSkinClass();
captionClass = captionClass != null ? captionClass + " " + captionClass
: captionSkinClass;
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, captionClass,
"captionClass");
@@ -197,34 +240,49 @@
org.richfaces.component.UIColumn column = (org.richfaces.component.UIColumn)
component;
if(isSortable(column)) {
-
+
boolean enableAsc=false, enableDesc = false, enableUnsort = false;
- if(Ordering.ASCENDING.equals(column.getSortOrder())) {
+ SortOrder sortOrder = column.getSortOrder();
+
+ if(SortOrder.ASCENDING.equals(sortOrder)) {
enableAsc = true;
- } else if(Ordering.DESCENDING.equals(column.getSortOrder())){
+ } else if(SortOrder.DESCENDING.equals(sortOrder)){
enableDesc = true;
} else {
enableUnsort = true;
}
-
- encodeSortControls(context, writer, column, enableAsc, enableDesc,
enableUnsort);
+
+// encodeSortControls(context, writer, column, enableAsc, enableDesc,
enableUnsort);
+
+ //encode sorting hidden input
+ /**
+ writer.startElement(HTML.INPUT_ELEM, column);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, column.getClientId(context) +
":sorting", null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, column.getClientId(context) +
":sorting", null);
+ writer.writeAttribute(HTML.TYPE_ATTR, "hidden",null);
+ writer.writeAttribute(HTML.VALUE_ATTRIBUTE, sortOrder, null);
+ writer.endElement(HTML.INPUT_ELEM);
+ */
}
writer.endElement(HTML.SPAN_ELEM);
}
public void encodeSortControls(FacesContext context, ResponseWriter writer,
org.richfaces.component.UIColumn column, boolean enableAsc, boolean enableDesc, boolean
enableUnsort) throws IOException {
-
+ /*
String sortIconAsc = column.getSortIconAsc();
String sortIconDesc = column.getSortIconDesc();
String sortIconUnsort = column.getSortIconUnsort();
+ String clientId = column.getClientId(context);
+
//TODO: anton - add styles attribute for sortControls
+
//encode asc control
writer.startElement(HTML.IMG_ELEMENT, column);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, column.getClientId(context) +
":" + Ordering.ASCENDING, null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId + ":" +
Ordering.ASCENDING, null);
writer.writeAttribute(HTML.ALT_ATTRIBUTE, "", null);
writer.writeAttribute(HTML.SRC_ATTRIBUTE, sortIconAsc, null);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
"extdt-header-sort-img", null);
@@ -237,7 +295,7 @@
//encode desc control
writer.startElement(HTML.IMG_ELEMENT, column);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, column.getClientId(context) +
":" + Ordering.DESCENDING, null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId + ":" +
Ordering.DESCENDING, null);
writer.writeAttribute(HTML.ALT_ATTRIBUTE, "", null);
writer.writeAttribute(HTML.SRC_ATTRIBUTE, sortIconDesc, null);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
"extdt-header-sort-img", null);
@@ -249,7 +307,7 @@
//encode unsorted control
writer.startElement(HTML.IMG_ELEMENT, column);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, column.getClientId(context) +
":" + Ordering.UNSORTED, null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId + ":" +
Ordering.UNSORTED, null);
writer.writeAttribute(HTML.ALT_ATTRIBUTE, "", null);
writer.writeAttribute(HTML.SRC_ATTRIBUTE, sortIconUnsort, null);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
"extdt-header-sort-img", null);
@@ -259,6 +317,7 @@
}
writer.endElement(HTML.IMG_ELEMENT);
+ */
}
}
@@ -272,7 +331,6 @@
public void encodeEnd(FacesContext context, ResponseWriter writer, UIComponent
column, String facetName)
throws IOException {
-
}
}
@@ -282,7 +340,11 @@
}
public boolean isSortable(UIColumn column) {
- return (column.getAttributes().get("sortBy") != null);
+ if(column instanceof org.richfaces.component.UIColumn) {
+ //TODO: anton - add check for the "comparator" property
+ return
((org.richfaces.component.UIColumn)column).getValueExpression("sortBy") !=
null;
+ }
+ return false;
}
@Override
@@ -296,10 +358,11 @@
HashMap<String, Object> options = new HashMap<String, Object>();
options.put("sortMode", dataTable.getSortMode());
+ options.put("sortField", dataTable.getClientId() + ":sort");
+
-
HashMap<String, Object> columnsOption = new HashMap<String,
Object>();
-
+ /*
Iterator<UIComponent> columns = dataTable.columns();
while (columns.hasNext()) {
@@ -311,20 +374,96 @@
columnsOption.put(column.getClientId(context), columnOption);
HashMap<String, Object> sorting = new HashMap<String,
Object>();
- sorting.put("sortOrder", column.getSortOrder());
- sorting.put("sortEvent", column.getSortEvent());
- sorting.put("sortable", isSortable(column));
+ boolean sortable = isSortable(column);
+ if(sortable) {
+ sorting.put("sortOrder", column.getSortOrder());
+ sorting.put("sortEvent", column.getSortEvent());
+ }
+ sorting.put("sortable", sortable);
columnOption.put("sorting", sorting);
}
-
-
+
}
options.put("columns", columnsOption);
-
+ */
function.addParameter(options);
writer.writeText(function.toScript(), null);
writer.endElement(HTML.SCRIPT_ELEM);
}
+
+ public String getTableSkinClass() {
+ return "rich-table";
+ }
+
+ public String getCaptionSkinClass() {
+ return "rich-table-caption";
+ }
+
+ @Override
+ public String getFirstRowSkinClass() {
+ return "rich-table-first-row";
+ }
+
+ @Override
+ public String getRowSkinClass() {
+ return "rich-table-row";
+ }
+
+ public String getCellSkinClass() {
+ return "rich-table-cell";
+ }
+
+ public String getHeaderSkinClass() {
+ return "rich-table-header";
+ }
+
+ @Override
+ public String getHeaderFirstSkinClass() {
+ return "rich-table-header-first";
+ }
+
+ public String getHeaderCellSkinClass() {
+ return "rich-table-header-cell";
+ }
+
+ public String getColumnHeaderSkinClass() {
+ return "rich-table-subheader";
+ }
+
+ @Override
+ public String getColumnHeaderFirstSkinClass() {
+ return "rich-table-subheader-first";
+ }
+
+ public String getColumnHeaderCellSkinClass() {
+ return "rich-table-subheader-cell";
+ }
+
+ public String getColumnFooterSkinClass() {
+ return "rich-table-subfooter";
+ }
+
+ @Override
+ public String getColumnFooterFirstSkinClass() {
+ return "rich-table-subfooter-first";
+ }
+
+ public String getColumnFooterCellSkinClass() {
+ return "rich-table-subfooter-cell";
+ }
+
+ public String getFooterSkinClass() {
+ return "rich-table-footer";
+ }
+
+ @Override
+ public String getFooterFirstSkinClass() {
+ return "rich-table-footer-first";
+ }
+
+ public String getFooterCellSkinClass() {
+ return "rich-table-footer-cell";
+ }
}
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-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRowsRenderer.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -180,4 +180,37 @@
writer.writeAttribute(HTML.STYLE_ATTRIBUTE, toEncode.toString(), null);
}
}
+
+ public abstract String getTableSkinClass();
+
+ public abstract String getFirstRowSkinClass();
+
+ public abstract String getRowSkinClass();
+
+ public abstract String getHeaderCellSkinClass();
+
+ public abstract String getHeaderSkinClass();
+
+ public abstract String getHeaderFirstSkinClass();
+
+ public abstract String getColumnHeaderCellSkinClass();
+
+ public abstract String getColumnHeaderSkinClass();
+
+ public abstract String getColumnHeaderFirstSkinClass();
+
+ public abstract String getFooterCellSkinClass();
+
+ public abstract String getFooterSkinClass();
+
+ public abstract String getFooterFirstSkinClass();
+
+ public abstract String getColumnFooterCellSkinClass();
+
+ public abstract String getColumnFooterSkinClass();
+
+ public abstract String getColumnFooterFirstSkinClass();
+
+ public abstract String getCellSkinClass();
+
}
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-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -479,4 +479,100 @@
// TODO Auto-generated method stub
}
+
+ @Override
+ public String getCellSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnFooterCellSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnFooterFirstSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnFooterSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnHeaderCellSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnHeaderFirstSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnHeaderSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getFirstRowSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getFooterCellSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getFooterFirstSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getFooterSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getHeaderCellSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getHeaderFirstSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getHeaderSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getRowSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getTableSkinClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/HeaderEncodeStrategy.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/HeaderEncodeStrategy.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/HeaderEncodeStrategy.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -26,8 +26,9 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-
+//TODO - anton move to the api
public interface HeaderEncodeStrategy {
+
public abstract void encodeBegin(FacesContext context, ResponseWriter writer,
UIComponent column, String facetName) throws IOException;
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -22,9 +22,9 @@
encodeHeaderFacet(writer, context, subTable);
- String rowClass = subTable.getRowSkinClass();
- String cellClass = subTable.getCellSkinClass();
- String firstClass = subTable.getFirstRowSkinClass();
+ String rowClass = getRowSkinClass();
+ String cellClass = getCellSkinClass();
+ String firstClass = getFirstRowSkinClass();
rowClass = mergeStyleClasses("rowClass", rowClass, subTable);
cellClass = mergeStyleClasses("cellClass", cellClass, subTable);
@@ -83,4 +83,92 @@
// TODO Auto-generated method stub
}
+
+
+ @Override
+ public String getRowSkinClass() {
+ return "rich-subtable-row";
+ }
+
+ @Override
+ public String getFirstRowSkinClass() {
+ return "rich-subtable-first-row";
+ }
+
+ public String getHeaderRowSkinClass() {
+ return "rich-subtable-header-row";
+ }
+
+ public String getHeaderFirstRowSkinClass() {
+ return "rich-subtable-header-first";
+ }
+
+ public String getCellSkinClass() {
+ return "rich-subtable-cell";
+ }
+
+ public String getHeaderCellSkinClass() {
+ return "rich-subtable-header-cell";
+ }
+
+
+ public String getColumnHeaderCellSkinClass() {
+ return "rich-subtable-subheader-cell";
+ }
+
+ public String getColumnHeaderSkinClass() {
+ return "rich-subtable-subheader";
+ }
+
+ public String getFooterCellSkinClass() {
+ return "rich-subtable-footer-cell";
+ }
+
+ public String getFooterSkinClass() {
+ return "rich-subtable-footer";
+ }
+
+ public String getFooterFirstRowSkinClass() {
+ return "rich-subtable-footer-first";
+ }
+
+ public String getColumnFooterCellSkinClass() {
+ return "rich-subtable-subfooter-cell";
+ }
+
+ public String getColumnFooterSkinClass() {
+ return "rich-subtable-subfooter-cell";
+ }
+
+ public String getTableSkinClass() {
+ return null;
+ }
+
+ public String getTableHeadSkinClass() {
+ return null;
+ }
+
+ @Override
+ public String getColumnFooterFirstSkinClass() {
+ return "rich-subtable-subfooter-first"; }
+
+ @Override
+ public String getColumnHeaderFirstSkinClass() {
+ return "rich-subtable-subheader-first";
+ }
+
+ @Override
+ public String getFooterFirstSkinClass() {
+ return "rich-subtable-footer-first";
+ }
+
+ @Override
+ public String getHeaderFirstSkinClass() {
+ return "rich-subtable-header-first";
+ }
+
+ @Override
+ public String getHeaderSkinClass() {
+ return "rich-subtable-header";
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -27,6 +27,7 @@
*/
@ResourceDependencies( {@ResourceDependency(library = "javax.faces", name =
"jsf-uncompressed.js"),
@ResourceDependency(name = "richfaces.js"),
@ResourceDependency(name="richfaces-queue.js"), @ResourceDependency(name =
"toggler.js")})
+
public abstract class ToggleControlRendererBase extends RendererBase {
private static final String MANAGER_SCRIPT =
"RichFaces.ui.ToggleManager.addToggler(new
RichFaces.ui.Toggle(''{0}'', {1}));";
@@ -197,14 +198,14 @@
public String getScript(UIToggleControl toggleControl, String switchType, boolean
isExpanded) {
String pattern = null;
-
+ /*
if (switchType.equals(UISubTable.SWITCH_TYPE_CLIENT)) {
pattern = CLIENT_TOGGLE_SCRIPT;
} else if (switchType.equals(UISubTable.SWITCH_TYPE_AJAX)) {
pattern = AJAX_TOGGLE_SCRIPT;
} else {
pattern = SERVER_TOGGLE_SCRIPT;
- }
+ }*/
String toggleId = toggleControl.getClientId();
return MessageFormat.format(pattern, toggleId, isExpanded);
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TogglerBehaviorRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TogglerBehaviorRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/TogglerBehaviorRenderer.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,72 @@
+package org.richfaces.renderkit;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.context.FacesContext;
+import javax.faces.render.ClientBehaviorRenderer;
+import javax.faces.render.FacesBehaviorRenderer;
+import javax.faces.render.RenderKitFactory;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.richfaces.component.behavior.ToggleBehavior;
+
+(a)FacesBehaviorRenderer(rendererType="org.richfaces.behavior.ToggleBehavior",
renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT)
+public class TogglerBehaviorRenderer extends ClientBehaviorRenderer {
+
+ private String SCRIPT_NAME = "RichFaces.Event.callHandlerById";
+
+ private String SCRIPT_EMPTY = "";
+
+// RichFaces.Event.callHandlerById('form1:j_idt6', 'RICH:sort',
{state: 'expanded'});
+ @Override
+ public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior
behavior) {
+
+ String script = SCRIPT_EMPTY;
+
+ if(behavior instanceof ToggleBehavior) {
+
+ ToggleBehavior toggleBehavior = (ToggleBehavior)behavior;
+
+ UIComponent toggleComponent = findComponent(behaviorContext,
toggleBehavior.getToggleComponentId());
+ UIComponent toggleSource = findComponent(behaviorContext,
toggleBehavior.getToggleSource());
+
+
+ String toggleComponentId =
toggleComponent.getClientId(behaviorContext.getFacesContext());
+ String toggleSourceId =
toggleSource.getClientId(behaviorContext.getFacesContext());
+
+ String toggleEventType = toggleBehavior.getToggleEvent();
+
+ JSFunction function = new JSFunction(SCRIPT_NAME);
+ function.addParameter(toggleComponentId);
+ function.addParameter(toggleEventType);
+
+ Map <String, Object> data = new HashMap<String, Object>();
+ function.addParameter(data);
+ data.put("source", toggleSourceId);
+
+ function.appendScript(new StringBuffer());
+ script = function.toScript();
+ }
+
+ return script;
+ }
+
+ private UIComponent findComponent(ClientBehaviorContext behaviorContext, String id)
{
+ UIComponent component = behaviorContext.getComponent();
+ //TODO: anton - check id == null!!!
+ //TODO: anton - should found component implement marker interface e.g.
ToggleAble ???
+ return RendererUtils.getInstance().findComponentFor(component, id);
+ }
+
+ @Override
+ public void decode(FacesContext context, UIComponent component, ClientBehavior
behavior) {
+ super.decode(context, component, behavior);
+ }
+
+
+}
Added:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/taglib/DataTableHandler.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/taglib/DataTableHandler.java
(rev 0)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/taglib/DataTableHandler.java 2010-02-19
16:45:49 UTC (rev 16472)
@@ -0,0 +1,58 @@
+package org.richfaces.taglib;
+
+import javax.el.MethodExpression;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.richfaces.component.UIDataTable;
+
+public class DataTableHandler extends ComponentHandler {
+
+ private static final DataTableHandlerMetaRule METARULE = new
DataTableHandlerMetaRule();
+
+ public DataTableHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset m = super.createMetaRuleset(type);
+ m.addRule(METARULE);
+ return m;
+ }
+
+ static class DataTableHandlerMetaRule extends MetaRule {
+
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
+ if (meta.isTargetInstanceOf(UIDataTable.class) &&
"sortingListener".equals(name)) {
+ return new DataTableMapper(attribute);
+ }
+ return null;
+ }
+
+ }
+
+ static class DataTableMapper extends Metadata {
+
+ private static final Class[] SIGNATURE = new Class[] {
org.richfaces.event.SortingEvent.class };
+
+ private final TagAttribute attribute;
+
+ public DataTableMapper(TagAttribute attribute) {
+ this.attribute = attribute;
+ }
+
+ @Override
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ MethodExpression methodExpression = attribute.getMethodExpression(ctx, null,
SIGNATURE);
+ ((UIDataTable) instance).setSortingListener(methodExpression);
+ }
+ }
+}
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-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/datatable.js 2010-02-19
16:45:49 UTC (rev 16472)
@@ -9,16 +9,24 @@
this.initializeColumns(options.columns);
};
+ jQuery.extend(richfaces.ui.DataTable, {
+ ASCENDING :'ASCENDING',
+ DESCENDING : 'DESCENDING',
+ UNSORTED : 'UNSORTED',
+ SINGLE: 'single',
+ MULTI: 'multi'
+ });
+
jQuery.extend(richfaces.ui.DataTable.prototype, ( function () {
var columns = {};
-
+
var convertId = function (id){
return id.replace(/:/g, "\\:");
};
var getElement = function (id) {
- return $("#" + convertId(id));
+ return jQuery("#" + convertId(id));
};
return {
@@ -42,7 +50,7 @@
var column = e.data;
column.toggleSortControl(e);
- if(this.sortMode == 'single') {
+ if(this.sortMode == richfaces.ui.DataTable.SINGLE) {
for(var x in columns) {
if(columns[x].id != column.id) {
columns[x].resetSortControl();
@@ -64,8 +72,11 @@
richfaces.ui.Column = function(id, options) {
this.id = id;
this.sortable = options.sorting.sortable;
- this.sortOrder = options.sorting.sortOrder;
- this.sortEvent = options.sorting.sortEvent;
+ //TODO: anton move to another place???
+ if(this.sortable) {
+ this.sortOrder = options.sorting.sortOrder;
+ this.sortEvent = options.sorting.sortEvent;
+ }
this.initializeControls(id);
};
@@ -76,9 +87,14 @@
};
var getElement = function (id) {
- return $("#" + convertId(id));
- };
+ return jQuery("#" + convertId(id));
+ };
+ var saveOrder = function(newOrder) {
+ var input = getElement(this.id + ":sorting");
+ input.attr("value",newOrder);
+ };
+
return {
initializeControls: function(id) {
this.asc = getElement(id+':ASCENDING');
@@ -88,30 +104,33 @@
toggleSortControl: function(e) {
- if(this.sortOrder == "ASCENDING") {
+ if(this.sortOrder == richfaces.ui.DataTable.ASCENDING) {
this.asc.hide();
this.unsort.hide();
this.desc.show();
- this.sortOrder = "DESCENDING";
+ this.sortOrder = richfaces.ui.DataTable.DESCENDING;
- } else if(this.sortOrder == "DESCENDING") {
+ } else if(this.sortOrder == richfaces.ui.DataTable.DESCENDING) {
this.asc.show();
this.unsort.hide();
this.desc.hide();
- this.sortOrder = "ASCENDING";
+ this.sortOrder = richfaces.ui.DataTable.ASCENDING;
- } else if(this.sortOrder == "UNSORTED") {
+ } else if(this.sortOrder == richfaces.ui.DataTable.UNSORTED) {
this.asc.hide();
this.unsort.hide();
this.desc.show();
- this.sortOrder = "DESCENDING";
+ this.sortOrder = richfaces.ui.DataTable.DESCENDING;
}
+
+ saveOrder.call(this, this.sortOrder);
},
resetSortControl: function(){
this.asc.hide();
this.desc.hide();
this.unsort.show();
+ saveOrder.call(this, richfaces.ui.DataTable.UNSORTED);
}
}
})());
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js 2010-02-19
11:03:52 UTC (rev 16471)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/toggler.js 2010-02-19
16:45:49 UTC (rev 16472)
@@ -76,8 +76,7 @@
return {
getElement : function (id) {
- // TODO: use jQuery instead of $
- return $("#" + convertId(id));
+ return jQuery("#" + convertId(id));
},
saveState : function(state) {