Author: abelevich
Date: 2009-12-07 08:22:33 -0500 (Mon, 07 Dec 2009)
New Revision: 16083
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/DataIterator.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/Expandable.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/IteratorBase.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/UIExtendedDataTable.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/UIToggleControl.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/event/ToggleEvent.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/event/ToggleListener.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/ColumnVisualModel.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/DataTableVisualModel.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/SubTableVisualModel.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/DataTableVisualModelImpl.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/SubTableVisualModelImpl.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.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/DataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.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/RowHolder.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolderBase.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/java/org/richfaces/taglib/SubTableHandler.java
Log:
checkstyle
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/ColumnsIterator.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -26,30 +26,29 @@
/**
* Iterator for all children table columns.
+ *
* @author asmirnov
- *
+ *
*/
class ColumnsIterator extends IteratorBase<UIComponent> {
-
- protected Iterator<UIComponent> childrenIterator;
-
-
- public ColumnsIterator(UIComponent dataTable) {
- this.childrenIterator = dataTable.getChildren().iterator();
- }
+ protected Iterator<UIComponent> childrenIterator;
- protected UIComponent nextItem(){
- while (childrenIterator != null && childrenIterator.hasNext()) {
- UIComponent child = childrenIterator.next();
- if (child instanceof javax.faces.component.UIColumn || child instanceof Column) {
- return child;
- }
- }
-
- //TODO nick - free childrenIterator field
-
- return null;
- }
-
+ public ColumnsIterator(UIComponent dataTable) {
+ this.childrenIterator = dataTable.getChildren().iterator();
+ }
+
+ protected UIComponent nextItem() {
+ while (childrenIterator != null && childrenIterator.hasNext()) {
+ UIComponent child = childrenIterator.next();
+ if (child instanceof javax.faces.component.UIColumn || child instanceof
Column) {
+ return child;
+ }
+ }
+
+ // TODO nick - free childrenIterator field
+
+ return null;
+ }
+
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/DataIterator.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -25,58 +25,57 @@
import javax.faces.component.UIComponent;
//TODO nick - rename to include component name
-class DataIterator extends IteratorBase <UIComponent> {
+class DataIterator extends IteratorBase<UIComponent> {
- private Iterator<UIComponent> facetsIterator;
-
- private Iterator<UIComponent> childrenIterator;
-
+ private Iterator<UIComponent> facetsIterator;
- public DataIterator(UIDataTableBase dataTable) {
- this.childrenIterator = dataTable.getChildren().iterator();
- this.facetsIterator = dataTable.getFacets().values().iterator();
- }
+ private Iterator<UIComponent> childrenIterator;
- protected UIComponent nextItem() {
-
- UIComponent nextColumn = null;
- while (nextColumn == null && childrenIterator.hasNext()) {
- UIComponent child = childrenIterator.next();
- //TODO nick - why non-rendered children are filtered?
- //TODO nick - should be (child instanceof UIColumn || child instanceof Column)?
- if ((child instanceof UIColumn) || (child instanceof Column)) {
- nextColumn = child;
- } else if(checkAjaxComponent(child)) {
- nextColumn = child;
- }
- }
-
- //TODO nick - free childrenIterator
-
- // ???
- while (nextColumn == null && facetsIterator.hasNext()) {
- UIComponent component = facetsIterator.next();
- if(checkAjaxComponent(component)){
- nextColumn = component;
- }
- }
-
- //TODO nick - free facetsIterator
-
- return nextColumn;
- }
-
- protected Iterator<UIComponent> getFacetsIterator() {
- return this.facetsIterator;
- }
-
- protected Iterator<UIComponent> getChildrenIterator() {
- return this.childrenIterator;
- }
-
- //TODO nick - what's this for?
- protected boolean checkAjaxComponent(UIComponent child) {
- return false;
- }
-
+ public DataIterator(UIDataTableBase dataTable) {
+ this.childrenIterator = dataTable.getChildren().iterator();
+ this.facetsIterator = dataTable.getFacets().values().iterator();
+ }
+
+ protected UIComponent nextItem() {
+
+ UIComponent nextColumn = null;
+ while (nextColumn == null && childrenIterator.hasNext()) {
+ UIComponent child = childrenIterator.next();
+ // TODO nick - why non-rendered children are filtered?
+ // TODO nick - should be (child instanceof UIColumn || child instanceof
Column)?
+ if ((child instanceof UIColumn) || (child instanceof Column)) {
+ nextColumn = child;
+ } else if (checkAjaxComponent(child)) {
+ nextColumn = child;
+ }
+ }
+
+ // TODO nick - free childrenIterator
+
+ // ???
+ while (nextColumn == null && facetsIterator.hasNext()) {
+ UIComponent component = facetsIterator.next();
+ if (checkAjaxComponent(component)) {
+ nextColumn = component;
+ }
+ }
+
+ // TODO nick - free facetsIterator
+
+ return nextColumn;
+ }
+
+ protected Iterator<UIComponent> getFacetsIterator() {
+ return this.facetsIterator;
+ }
+
+ protected Iterator<UIComponent> getChildrenIterator() {
+ return this.childrenIterator;
+ }
+
+ // TODO nick - what's this for?
+ protected boolean checkAjaxComponent(UIComponent child) {
+ return false;
+ }
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/Expandable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/Expandable.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/Expandable.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -5,17 +5,17 @@
import org.richfaces.event.ToggleListener;
public interface Expandable {
-
- public boolean isExpanded();
-
- public void addToggleListener(ToggleListener listener);
-
- public void removeToggleListener(ToggleListener listener);
-
- public ToggleListener [] getToggleListeners();
-
- public void setToggleListener(MethodExpression toggleExpression);
-
- public MethodExpression getToggleListener();
-
+
+ public boolean isExpanded();
+
+ public void addToggleListener(ToggleListener listener);
+
+ public void removeToggleListener(ToggleListener listener);
+
+ public ToggleListener[] getToggleListeners();
+
+ public void setToggleListener(MethodExpression toggleExpression);
+
+ public MethodExpression getToggleListener();
+
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/FixedChildrenIterator.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -24,60 +24,59 @@
import javax.faces.component.UIComponent;
-
class FixedChildrenIterator extends DataIterator {
-
- private Iterator<UIComponent> currentColumnIterator;
-
- public FixedChildrenIterator(UIDataTableBase dataTable) {
- super(dataTable);
- }
-
- @Override
- protected UIComponent nextItem() {
- UIComponent next = null;
-
- if(currentColumnIterator != null && currentColumnIterator.hasNext()) {
- next = currentColumnIterator.next();
- checkColumnIterator();
- }
-
- if(next == null) {
- Iterator <UIComponent> childrenIterator = getChildrenIterator();
- while(next == null && childrenIterator.hasNext()) {
- UIComponent child = childrenIterator.next();
- if((child instanceof UIColumn) && child.isRendered()) {
- currentColumnIterator = getChildFacetIterator(child);
- next = nextItem();
- } else if(checkAjaxComponent(child)) {
- next = child;
- }
- }
- }
-
- if (next == null) {
- next = getNextFacet();
- }
- return next;
- }
-
- protected UIComponent getNextFacet() {
- Iterator<UIComponent> facetsIterator = getFacetsIterator();
- //TODO nick - while -> if
- while(facetsIterator.hasNext()) {
- return facetsIterator.next();
- }
- return null;
- }
-
- protected void checkColumnIterator() {
- if (!currentColumnIterator.hasNext()) {
- currentColumnIterator = null;
- }
- }
-
- protected Iterator<UIComponent> getChildFacetIterator(UIComponent component) {
- return component.getFacets().values().iterator();
- }
+ private Iterator<UIComponent> currentColumnIterator;
+
+ public FixedChildrenIterator(UIDataTableBase dataTable) {
+ super(dataTable);
+ }
+
+ @Override
+ protected UIComponent nextItem() {
+ UIComponent next = null;
+
+ if (currentColumnIterator != null && currentColumnIterator.hasNext()) {
+ next = currentColumnIterator.next();
+ checkColumnIterator();
+ }
+
+ if (next == null) {
+ Iterator<UIComponent> childrenIterator = getChildrenIterator();
+ while (next == null && childrenIterator.hasNext()) {
+ UIComponent child = childrenIterator.next();
+ if ((child instanceof UIColumn) && child.isRendered()) {
+ currentColumnIterator = getChildFacetIterator(child);
+ next = nextItem();
+ } else if (checkAjaxComponent(child)) {
+ next = child;
+ }
+ }
+ }
+
+ if (next == null) {
+ next = getNextFacet();
+ }
+ return next;
+ }
+
+ protected UIComponent getNextFacet() {
+ Iterator<UIComponent> facetsIterator = getFacetsIterator();
+ // TODO nick - while -> if
+ while (facetsIterator.hasNext()) {
+ return facetsIterator.next();
+ }
+ return null;
+ }
+
+ protected void checkColumnIterator() {
+ if (!currentColumnIterator.hasNext()) {
+ currentColumnIterator = null;
+ }
+ }
+
+ protected Iterator<UIComponent> getChildFacetIterator(UIComponent component) {
+ return component.getFacets().values().iterator();
+ }
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/IteratorBase.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/IteratorBase.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/IteratorBase.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -7,46 +7,46 @@
* @author Anton Belevich
* @author Nick Belaevski
*/
-//TODO nick - rename this class
+// TODO nick - rename this class
public abstract class IteratorBase<E> implements Iterator<E> {
-
- private boolean isCompleted = false;
-
- private E next = null;
- private void setupNext() {
- if (!isCompleted) {
- if (next == null) {
- next = nextItem();
+ private boolean isCompleted = false;
- if (next == null) {
- isCompleted = true;
- }
- }
- }
- }
-
- public boolean hasNext() {
- setupNext();
-
- return next != null;
- }
+ private E next = null;
- public E next() {
- setupNext();
-
- if (next == null) {
- throw new NoSuchElementException();
- }
-
- E result = next;
- next = null;
- return result;
- }
+ private void setupNext() {
+ if (!isCompleted) {
+ if (next == null) {
+ next = nextItem();
- public void remove() {
- throw new UnsupportedOperationException("Iterator is read-only");
- }
-
- abstract protected E nextItem();
+ if (next == null) {
+ isCompleted = true;
+ }
+ }
+ }
+ }
+
+ public boolean hasNext() {
+ setupNext();
+
+ return next != null;
+ }
+
+ public E next() {
+ setupNext();
+
+ if (next == null) {
+ throw new NoSuchElementException();
+ }
+
+ E result = next;
+ next = null;
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("Iterator is read-only");
+ }
+
+ protected abstract E nextItem();
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/SubtableFixedChildrenIterator.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -24,16 +24,16 @@
/**
* @author asmirnov
- *
+ *
*/
public class SubtableFixedChildrenIterator extends FixedChildrenIterator {
- public SubtableFixedChildrenIterator(UIDataTableBase dataTable) {
- super(dataTable);
- }
+ public SubtableFixedChildrenIterator(UIDataTableBase dataTable) {
+ super(dataTable);
+ }
- @Override
- protected UIComponent getNextFacet() {
- return null;
- }
+ @Override
+ protected UIComponent getNextFacet() {
+ return null;
+ }
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -1,14 +1,13 @@
package org.richfaces.component;
+public abstract class UIColumn extends javax.faces.component.UIColumn implements Column
{
-public abstract class UIColumn extends javax.faces.component.UIColumn implements Column
{
-
- public abstract int getRowspan();
- public abstract void setRowspan(int rowspan);
-
- public abstract int getColspan();
- public abstract void setColspan(int colspan);
-
+ public abstract int getRowspan();
+ public abstract void setRowspan(int rowspan);
+
+ public abstract int getColspan();
+
+ public abstract void setColspan(int colspan);
+
}
-
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumnGroup.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -32,47 +32,47 @@
/**
* JSF component class
- *
+ *
*/
public abstract class UIColumnGroup extends UIPanel implements Row, Column {
-
- public static final String COMPONENT_TYPE = "org.richfaces.Colgroup";
-
- public static final String COMPONENT_FAMILY = "org.richfaces.Colgroup";
-
- public Iterator<UIComponent> columns(){
- return new ColumnsIterator(this);
- }
- public boolean isBreakBefore() {
- return true;
- }
-
- public void setBreakBefore(boolean newBreakBefore) {
- throw new IllegalStateException("Property 'breakBefore' for subtable is
read-only");
- }
-
- public void setRowKey(FacesContext context, Object rowKey) {
- // columnGroup doesn't have data model
- }
-
- public void walk(FacesContext context, DataVisitor visitor, Object argument) {
- if(!(argument instanceof RowHolder)) {
- return;
- }
-
- visitor.process(context, null, argument);
- }
-
- public String getCellSkinClass() {
- return null;
- }
-
- public String getRowSkinClass() {
- return null;
- }
-
- public String getFirstRowSkinClass() {
- return null;
- }
+ public static final String COMPONENT_TYPE = "org.richfaces.Colgroup";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Colgroup";
+
+ public Iterator<UIComponent> columns() {
+ return new ColumnsIterator(this);
+ }
+
+ public boolean isBreakBefore() {
+ return true;
+ }
+
+ public void setBreakBefore(boolean newBreakBefore) {
+ throw new IllegalStateException("Property 'breakBefore' for subtable
is read-only");
+ }
+
+ public void setRowKey(FacesContext context, Object rowKey) {
+ // columnGroup doesn't have data model
+ }
+
+ public void walk(FacesContext context, DataVisitor visitor, Object argument) {
+ if (!(argument instanceof RowHolder)) {
+ return;
+ }
+
+ visitor.process(context, null, argument);
+ }
+
+ public String getCellSkinClass() {
+ return null;
+ }
+
+ public String getRowSkinClass() {
+ return null;
+ }
+
+ public String getFirstRowSkinClass() {
+ return null;
+ }
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -9,95 +9,94 @@
/**
* @author Anton Belevich
- *
+ *
*/
public abstract class UIDataTable extends UIDataTableBase {
-
- enum PropertyKeys {
- visualModel
- }
-
-
- public DataTableVisualModel getVisualModel(){
- return (DataTableVisualModel) getStateHelper().eval(PropertyKeys.visualModel);
- }
-
- public void setVisualModel(DataTableVisualModel dataTableVisualModel) {
- getStateHelper().put(PropertyKeys.visualModel, dataTableVisualModel);
- }
-
- @Override
- protected DataComponentState createComponentState() {
- DataTableState state = new DataTableState(getFirst(), getRows());
- DataTableVisualModel model = getVisualModel();
-
- if(model == null) {
- model = new DataTableVisualModelImpl();
- }
- state.setVisualModel(model);
-
- return state;
- }
-
- public String getCellSkinClass() {
- return "rich-table-cell";
- }
-
- public String getRowSkinClass() {
- return "rich-table-row";
- }
-
- public String getFirstRowSkinClass() {
- return "rich-table-firstrow";
- }
-
- public String getHeaderCellSkinClass() {
- return "rich-table-header-cell";
- }
-
- public String getHeaderRowSkinClass() {
- return "rich-table-header-continue";
- }
-
- public String getHeaderFirstRowSkinClass() {
- return "rich-table-header";
- }
-
- public String getColumnHeaderCellSkinClass() {
- return "rich-table-subheader-cell";
- }
-
- public String getColumnHeaderSkinClass() {
- return "rich-table-subheader";
- }
-
- @Override
- public String getFooterCellSkinClass() {
- return "rich-table-footer-cell";
- }
-
- @Override
- public String getFooterRowSkinClass() {
- return "rich-table-footer-continue";
- }
-
- @Override
- public String getFooterFirstRowSkinClass() {
- return "rich-table-footer";
- }
-
- @Override
- public String getColumnFooterCellSkinClass() {
- return "rich-table-subfooter-cell";
- }
-
- @Override
- public String getColumnFooterSkinClass() {
- return "rich-table-subfooter-cell";
- }
-
- public UIComponent getCaption() {
- return getFacet("caption");
- }
-}
+
+ enum PropertyKeys {
+ visualModel
+ }
+
+ public DataTableVisualModel getVisualModel() {
+ return (DataTableVisualModel) getStateHelper().eval(PropertyKeys.visualModel);
+ }
+
+ public void setVisualModel(DataTableVisualModel dataTableVisualModel) {
+ getStateHelper().put(PropertyKeys.visualModel, dataTableVisualModel);
+ }
+
+ @Override
+ protected DataComponentState createComponentState() {
+ DataTableState state = new DataTableState(getFirst(), getRows());
+ DataTableVisualModel model = getVisualModel();
+
+ if (model == null) {
+ model = new DataTableVisualModelImpl();
+ }
+ state.setVisualModel(model);
+
+ return state;
+ }
+
+ public String getCellSkinClass() {
+ return "rich-table-cell";
+ }
+
+ public String getRowSkinClass() {
+ return "rich-table-row";
+ }
+
+ public String getFirstRowSkinClass() {
+ return "rich-table-firstrow";
+ }
+
+ public String getHeaderCellSkinClass() {
+ return "rich-table-header-cell";
+ }
+
+ public String getHeaderRowSkinClass() {
+ return "rich-table-header-continue";
+ }
+
+ public String getHeaderFirstRowSkinClass() {
+ return "rich-table-header";
+ }
+
+ public String getColumnHeaderCellSkinClass() {
+ return "rich-table-subheader-cell";
+ }
+
+ public String getColumnHeaderSkinClass() {
+ return "rich-table-subheader";
+ }
+
+ @Override
+ public String getFooterCellSkinClass() {
+ return "rich-table-footer-cell";
+ }
+
+ @Override
+ public String getFooterRowSkinClass() {
+ return "rich-table-footer-continue";
+ }
+
+ @Override
+ public String getFooterFirstRowSkinClass() {
+ return "rich-table-footer";
+ }
+
+ @Override
+ public String getColumnFooterCellSkinClass() {
+ return "rich-table-subfooter-cell";
+ }
+
+ @Override
+ public String getColumnFooterSkinClass() {
+ return "rich-table-subfooter-cell";
+ }
+
+ public UIComponent getCaption() {
+ return getFacet("caption");
+ }
+}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -6,54 +6,52 @@
public abstract class UIDataTableBase extends UISequence implements Row {
- public Iterator<UIComponent> columns() {
- return new ColumnsIterator(this);
- }
-
- @Override
- protected Iterator<UIComponent> fixedChildren() {
- return new FixedChildrenIterator(this);
- }
-
- @Override
- protected Iterator<UIComponent> dataChildren() {
-
- return new DataIterator(this);
- }
-
- public UIComponent getHeader() {
+ public Iterator<UIComponent> columns() {
+ return new ColumnsIterator(this);
+ }
+
+ @Override
+ protected Iterator<UIComponent> fixedChildren() {
+ return new FixedChildrenIterator(this);
+ }
+
+ @Override
+ protected Iterator<UIComponent> dataChildren() {
+
+ return new DataIterator(this);
+ }
+
+ public UIComponent getHeader() {
return getFacet("header");
}
-
- public UIComponent getFooter() {
+
+ public UIComponent getFooter() {
return getFacet("footer");
}
-
- public abstract String getHeaderCellSkinClass();
-
- public abstract String getHeaderRowSkinClass();
-
- public abstract String getHeaderFirstRowSkinClass();
-
- public abstract String getColumnHeaderCellSkinClass();
-
- public abstract String getColumnHeaderSkinClass();
-
- public abstract String getFooterCellSkinClass();
-
- public abstract String getFooterRowSkinClass();
-
- public abstract String getFooterFirstRowSkinClass();
-
- public abstract String getColumnFooterCellSkinClass();
-
- public abstract String getColumnFooterSkinClass();
-
-
- @Override
- public boolean getRendersChildren() {
- return true;
- }
-
+ public abstract String getHeaderCellSkinClass();
+
+ public abstract String getHeaderRowSkinClass();
+
+ public abstract String getHeaderFirstRowSkinClass();
+
+ public abstract String getColumnHeaderCellSkinClass();
+
+ public abstract String getColumnHeaderSkinClass();
+
+ public abstract String getFooterCellSkinClass();
+
+ public abstract String getFooterRowSkinClass();
+
+ public abstract String getFooterFirstRowSkinClass();
+
+ public abstract String getColumnFooterCellSkinClass();
+
+ public abstract String getColumnFooterSkinClass();
+
+ @Override
+ public boolean getRendersChildren() {
+ return true;
+ }
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -2,7 +2,7 @@
/**
* @author Anton Belevich
- *
+ *
*/
public abstract class UIExtendedDataTable extends UIDataTable {
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -39,261 +39,260 @@
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
- }
-
- 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;
- }
-
- public void setBreakBefore(boolean newBreakBefore) {
- throw new IllegalStateException("Property 'breakBefore' for subtable is
read-only");
- }
- public String getSortExpression() {
- // SubTable is not sortable element.
- return null;
- }
-
- public void setSortExpression(String sortExpression) {
- throw new IllegalArgumentException("subtable is not sortable element");
- }
-
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Object argument) {
- resetDataModel(context);
- super.walk(context, visitor, argument);
- }
-
- public String getSwichType(){
- return (String)getStateHelper().eval(PropertyKeys.switchType, SWITCH_TYPE_SERVER);
- }
-
- public void setSwitchType(String switchType){
- getStateHelper().put(PropertyKeys.switchType, switchType);
- }
-
- public SubTableState getCurrentComponentState() {
- DataComponentState dataComponentState = getComponentState();
- if(dataComponentState instanceof SubTableState) {
- DataTableState parentState = getParentState();
- parentState.addSubTableState((SubTableState)dataComponentState);
-
- return (SubTableState) dataComponentState;
- }
- return null;
- }
-
- public DataTableState getParentState() {
- DataTableState dataTableState = null;
-
- UIComponent component = getParent();
- if(component instanceof UIDataTable) {
- UIDataTable dataTable = (UIDataTable)component;
- DataComponentState state = dataTable.getComponentState();
-
- if(state instanceof DataTableState) {
- dataTableState = (DataTableState)state;
- }
- }
-
- return dataTableState;
- }
-
- @Override
- protected DataComponentState createComponentState() {
- DataComponentState state = null;
- DataTableState parentState = getParentState();
-
- if(parentState != null) {
- state = parentState.getChildState(getClientId());
- }
-
- if(state == null) {
- state = new SubTableState(getClientId(), getFirst(), getRows());
- }
-
- return state;
- }
-
- public void setExpanded(boolean expanded) {
- this.expanded = expanded;
- }
-
- public boolean isExpanded() {
- return getVisualModel().isExpanded();
- }
-
- public void setToggleListener(MethodExpression toggleExpression) {
- getStateHelper().put(PropertyKeys.toggleExpression, toggleExpression);
- }
-
- public MethodExpression getToggleListener() {
- return (MethodExpression) getStateHelper().eval(PropertyKeys.toggleExpression);
- }
-
- @Override
- public void queueEvent(FacesEvent event) {
- if(event instanceof ToggleEvent) {
- event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
- }
- super.queueEvent(event);
- }
-
- @Override
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- super.broadcast(event);
-
- if(event instanceof ToggleEvent) {
- ToggleEvent toggleEvent = (ToggleEvent)event;
-
- //not sure that this is right ... need to discuss
- SubTableState state = getCurrentComponentState();
- if(event.isAppropriateListener(state)) {
- toggleEvent.processListener(state);
- }
-
- MethodExpression expression = getToggleListener();
- if(expression != null) {
- expression.invoke(getFacesContext().getELContext(), new Object[]{toggleEvent});
- }
- }
- }
-
- public void addToggleListener(ToggleListener listener) {
- addFacesListener(listener);
- }
-
- public void removeToggleListener(ToggleListener listener) {
- removeFacesListener(listener);
- }
-
- public ToggleListener [] getToggleListeners() {
- return (ToggleListener[]) getFacesListeners(ToggleListener.class);
- }
-
- @Override
- public boolean getRendersChildren() {
- //TODO nick - why "false"?
- return false;
- }
-
- public String getCellSkinClass() {
- return "rich-subtable-cell";
- }
-
- public String getRowSkinClass() {
- return "rich-subtable-row";
- }
-
- public String getFirstRowSkinClass() {
- return "rich-subtable-first-row";
- }
-
- public String getHeaderCellSkinClass() {
- return "rich-subtable-header-cell";
- }
-
- public String getHeaderRowSkinClass() {
- return "rich-subtable-header-row";
- }
-
- public String getHeaderFirstRowSkinClass() {
- return "rich-subtable-header-first-row";
- }
-
- public String getColumnHeaderCellSkinClass() {
- return "rich-subtable-subheader-cell";
- }
-
- public String getColumnHeaderSkinClass() {
- return "rich-subtable-subheader";
- }
-
- @Override
- public String getFooterCellSkinClass() {
- return "rich-subtable-footer-cell";
- }
-
- @Override
- public String getFooterRowSkinClass() {
- return "rich-subtable-footer-continue";
- }
-
- @Override
- public String getFooterFirstRowSkinClass() {
- return "rich-subtable-footer";
- }
-
- @Override
- public String getColumnFooterCellSkinClass() {
- return "rich-subtable-subfooter-cell";
- }
-
- @Override
- public String getColumnFooterSkinClass() {
- return "rich-subtable-subfooter-cell";
- }
-
+ 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
+ }
+
+ 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;
+ }
+
+ public void setBreakBefore(boolean newBreakBefore) {
+ throw new IllegalStateException("Property 'breakBefore' for subtable
is read-only");
+ }
+
+ public String getSortExpression() {
+ // SubTable is not sortable element.
+ return null;
+ }
+
+ public void setSortExpression(String sortExpression) {
+ throw new IllegalArgumentException("subtable is not sortable
element");
+ }
+
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Object argument) {
+ resetDataModel(context);
+ super.walk(context, visitor, argument);
+ }
+
+ public String getSwichType() {
+ return (String) getStateHelper().eval(PropertyKeys.switchType,
SWITCH_TYPE_SERVER);
+ }
+
+ public void setSwitchType(String switchType) {
+ getStateHelper().put(PropertyKeys.switchType, switchType);
+ }
+
+ public SubTableState getCurrentComponentState() {
+ DataComponentState dataComponentState = getComponentState();
+ if (dataComponentState instanceof SubTableState) {
+ DataTableState parentState = getParentState();
+ parentState.addSubTableState((SubTableState) dataComponentState);
+
+ return (SubTableState) dataComponentState;
+ }
+ return null;
+ }
+
+ public DataTableState getParentState() {
+ DataTableState dataTableState = null;
+
+ UIComponent component = getParent();
+ if (component instanceof UIDataTable) {
+ UIDataTable dataTable = (UIDataTable) component;
+ DataComponentState state = dataTable.getComponentState();
+
+ if (state instanceof DataTableState) {
+ dataTableState = (DataTableState) state;
+ }
+ }
+
+ return dataTableState;
+ }
+
+ @Override
+ protected DataComponentState createComponentState() {
+ DataComponentState state = null;
+ DataTableState parentState = getParentState();
+
+ if (parentState != null) {
+ state = parentState.getChildState(getClientId());
+ }
+
+ if (state == null) {
+ state = new SubTableState(getClientId(), getFirst(), getRows());
+ }
+
+ return state;
+ }
+
+ public void setExpanded(boolean expanded) {
+ this.expanded = expanded;
+ }
+
+ public boolean isExpanded() {
+ return getVisualModel().isExpanded();
+ }
+
+ public void setToggleListener(MethodExpression toggleExpression) {
+ getStateHelper().put(PropertyKeys.toggleExpression, toggleExpression);
+ }
+
+ public MethodExpression getToggleListener() {
+ return (MethodExpression) getStateHelper().eval(PropertyKeys.toggleExpression);
+ }
+
+ @Override
+ public void queueEvent(FacesEvent event) {
+ if (event instanceof ToggleEvent) {
+ event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
+ }
+ super.queueEvent(event);
+ }
+
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+
+ if (event instanceof ToggleEvent) {
+ ToggleEvent toggleEvent = (ToggleEvent) event;
+
+ // not sure that this is right ... need to discuss
+ SubTableState state = getCurrentComponentState();
+ if (event.isAppropriateListener(state)) {
+ toggleEvent.processListener(state);
+ }
+
+ MethodExpression expression = getToggleListener();
+ if (expression != null) {
+ expression.invoke(getFacesContext().getELContext(), new Object[] {
toggleEvent });
+ }
+ }
+ }
+
+ public void addToggleListener(ToggleListener listener) {
+ addFacesListener(listener);
+ }
+
+ public void removeToggleListener(ToggleListener listener) {
+ removeFacesListener(listener);
+ }
+
+ public ToggleListener[] getToggleListeners() {
+ return (ToggleListener[]) getFacesListeners(ToggleListener.class);
+ }
+
+ @Override
+ public boolean getRendersChildren() {
+ // TODO nick - why "false"?
+ return false;
+ }
+
+ public String getCellSkinClass() {
+ return "rich-subtable-cell";
+ }
+
+ public String getRowSkinClass() {
+ return "rich-subtable-row";
+ }
+
+ public String getFirstRowSkinClass() {
+ return "rich-subtable-first-row";
+ }
+
+ public String getHeaderCellSkinClass() {
+ return "rich-subtable-header-cell";
+ }
+
+ public String getHeaderRowSkinClass() {
+ return "rich-subtable-header-row";
+ }
+
+ public String getHeaderFirstRowSkinClass() {
+ return "rich-subtable-header-first-row";
+ }
+
+ public String getColumnHeaderCellSkinClass() {
+ return "rich-subtable-subheader-cell";
+ }
+
+ public String getColumnHeaderSkinClass() {
+ return "rich-subtable-subheader";
+ }
+
+ @Override
+ public String getFooterCellSkinClass() {
+ return "rich-subtable-footer-cell";
+ }
+
+ @Override
+ public String getFooterRowSkinClass() {
+ return "rich-subtable-footer-continue";
+ }
+
+ @Override
+ public String getFooterFirstRowSkinClass() {
+ return "rich-subtable-footer";
+ }
+
+ @Override
+ public String getColumnFooterCellSkinClass() {
+ return "rich-subtable-subfooter-cell";
+ }
+
+ @Override
+ public String getColumnFooterSkinClass() {
+ return "rich-subtable-subfooter-cell";
+ }
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIToggleControl.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIToggleControl.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIToggleControl.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -3,51 +3,50 @@
import javax.faces.component.UIComponentBase;
public abstract class UIToggleControl extends UIComponentBase {
-
- public static final String COMPONENT_TYPE = "org.richfaces.ToggleControl";
+ public static final String COMPONENT_TYPE = "org.richfaces.ToggleControl";
+
public static final String COMPONENT_FAMILY =
"org.richfaces.ToggleControl";
-
-
+
enum PropertyKeys {
- expandControl, collapseControl, forId, event
+ expandControl, collapseControl, forId, event
}
-
+
@Override
public String getFamily() {
- return COMPONENT_FAMILY;
+ return COMPONENT_FAMILY;
}
-
- public String getExpandControl(){
- return (String) getStateHelper().eval(PropertyKeys.expandControl, null);
+
+ public String getExpandControl() {
+ return (String) getStateHelper().eval(PropertyKeys.expandControl, null);
}
-
+
public void setExpandControl(String expandControl) {
- getStateHelper().put(PropertyKeys.expandControl, expandControl);
+ getStateHelper().put(PropertyKeys.expandControl, expandControl);
}
-
+
public String getCollapseControl() {
- return (String) getStateHelper().eval(PropertyKeys.collapseControl, null);
+ return (String) getStateHelper().eval(PropertyKeys.collapseControl, null);
}
-
+
public void setCollapseControl(String collapseControl) {
- getStateHelper().put(PropertyKeys.collapseControl, collapseControl);
+ getStateHelper().put(PropertyKeys.collapseControl, collapseControl);
}
-
- public String getForId(){
- return (String)getStateHelper().eval(PropertyKeys.forId, null);
+
+ public String getForId() {
+ return (String) getStateHelper().eval(PropertyKeys.forId, null);
}
-
+
public void setForId(String forId) {
- getStateHelper().put(PropertyKeys.forId, forId);
+ getStateHelper().put(PropertyKeys.forId, forId);
}
-
+
public String getEvent() {
- return (String)getStateHelper().eval(PropertyKeys.event, "onclick");
-
+ return (String) getStateHelper().eval(PropertyKeys.event, "onclick");
+
}
-
+
public void setEvent(String event) {
- getStateHelper().put(PropertyKeys.event, event);
+ getStateHelper().put(PropertyKeys.event, event);
}
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -6,90 +6,97 @@
import org.richfaces.model.Ordering;
public class HtmlColumn extends UIColumn {
-
+
enum PropertyKeys {
- breakBefore, rowspan, colspan
+ breakBefore, rowspan, colspan
}
-
- public static final String COMPONENT_TYPE = "org.richfaces.Column";
+
+ 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();
- }
-
- public void setColspan(int colspan) {
- getStateHelper().put(PropertyKeys.colspan, Integer.valueOf(colspan));
- }
-
- public int getRowspan(){
- Integer rowspan = (Integer)getStateHelper().eval(PropertyKeys.rowspan,
Integer.MIN_VALUE);
- return rowspan.intValue();
- }
-
- public void setRowspan(int rowspan) {
- getStateHelper().put(PropertyKeys.rowspan, Integer.valueOf(rowspan));
- }
-
-
+ 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();
+ }
+
+ public void setColspan(int colspan) {
+ getStateHelper().put(PropertyKeys.colspan, Integer.valueOf(colspan));
+ }
+
+ public int getRowspan() {
+ Integer rowspan = (Integer) getStateHelper().eval(PropertyKeys.rowspan,
Integer.MIN_VALUE);
+ return rowspan.intValue();
+ }
+
+ public void setRowspan(int rowspan) {
+ getStateHelper().put(PropertyKeys.rowspan, Integer.valueOf(rowspan));
+ }
+
public MethodExpression getFilterMethod() {
- // TODO Auto-generated method stub
- return null;
- }
- public String getFilterValue() {
- return null;
- }
- public String getSortExpression() {
- // TODO Auto-generated method stub
- return null;
- }
- public Ordering getSortOrder() {
- // TODO Auto-generated method stub
- return null;
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- public boolean isSelfSorted() {
- // TODO Auto-generated method stub
- return false;
- }
- 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 setSelfSorted(boolean selfSorted) {
- // TODO Auto-generated method stub
-
- }
- public void setSortExpression(String sortExpression) {
- // TODO Auto-generated method stub
-
- }
- public void setSortOrder(Ordering sortOrder) {
- // TODO Auto-generated method stub
-
- }
- public void setSortable(boolean sortable) {
- // TODO Auto-generated method stub
- }
-
+ public String getFilterValue() {
+ return null;
+ }
+
+ public String getSortExpression() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Ordering getSortOrder() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isSelfSorted() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ 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 setSelfSorted(boolean selfSorted) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSortExpression(String sortExpression) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSortOrder(Ordering sortOrder) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSortable(boolean sortable) {
+ // TODO Auto-generated method stub
+ }
+
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumnGroup.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -5,71 +5,71 @@
import org.richfaces.component.UIColumnGroup;
import org.richfaces.model.Ordering;
-public class HtmlColumnGroup extends UIColumnGroup{
+public class HtmlColumnGroup extends UIColumnGroup {
- public MethodExpression getFilterMethod() {
- // TODO Auto-generated method stub
- return null;
- }
+ public MethodExpression getFilterMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
- public String getFilterValue() {
- // 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 String getSortExpression() {
+ // TODO Auto-generated method stub
+ return null;
+ }
- public Ordering getSortOrder() {
- // TODO Auto-generated method stub
- return null;
- }
+ public Ordering getSortOrder() {
+ // TODO Auto-generated method stub
+ return null;
+ }
- public boolean isSelfSorted() {
- // TODO Auto-generated method stub
- return false;
- }
+ public boolean isSelfSorted() {
+ // TODO Auto-generated method stub
+ return false;
+ }
- public boolean isSortable() {
- // TODO Auto-generated method stub
- return false;
- }
+ public boolean isSortable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
- public void setFilterMethod(MethodExpression methodExpression) {
- // TODO Auto-generated method stub
-
- }
+ public void setFilterMethod(MethodExpression methodExpression) {
+ // TODO Auto-generated method stub
- public void setFilterValue(String filterValue) {
- // TODO Auto-generated method stub
-
- }
+ }
- public void setSelfSorted(boolean selfSorted) {
- // 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 setSortOrder(Ordering sortOrder) {
- // TODO Auto-generated method stub
-
- }
+ public void setSelfSorted(boolean selfSorted) {
+ // TODO Auto-generated method stub
- public void setSortable(boolean sortable) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
+ }
+ public void setSortExpression(String sortExpression) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSortOrder(Ordering sortOrder) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSortable(boolean sortable) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlDataTable.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -3,17 +3,17 @@
import org.richfaces.component.UIDataTable;
public class HtmlDataTable extends UIDataTable {
-
+
public static final String COMPONENT_TYPE = "org.richfaces.DataTable";
-
+
public static final String COMPONENT_FAMILY = "org.richfaces.DataTable";
public HtmlDataTable() {
- setRendererType("org.richfaces.DataTableRenderer");
+ setRendererType("org.richfaces.DataTableRenderer");
}
-
+
@Override
public String getFamily() {
- return COMPONENT_FAMILY;
+ return COMPONENT_FAMILY;
}
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlExtendedDataTable.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -18,21 +18,23 @@
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
+ */
package org.richfaces.component.html;
import org.richfaces.component.UIExtendedDataTable;
-public class HtmlExtendedDataTable extends UIExtendedDataTable{
-
- public static final String COMPONENT_TYPE =
"org.richfaces.ExtendedDataTable";
-
- private static enum PropertyKeys {style, styleClass, frozenColumns}
-
+public class HtmlExtendedDataTable extends UIExtendedDataTable {
+
+ public static final String COMPONENT_TYPE =
"org.richfaces.ExtendedDataTable";
+
+ private static enum PropertyKeys {
+ style, styleClass, frozenColumns
+ }
+
public HtmlExtendedDataTable() {
- setRendererType("org.richfaces.ExtendedDataTableRenderer");
- }
-
+ setRendererType("org.richfaces.ExtendedDataTableRenderer");
+ }
+
public String getStyle() {
return (String) getStateHelper().eval(PropertyKeys.style, "");
}
@@ -48,7 +50,7 @@
public void setStyleClass(String styleClass) {
getStateHelper().put(PropertyKeys.styleClass, styleClass);
}
-
+
public Integer getFrozenColumns() {
return (Integer) getStateHelper().eval(PropertyKeys.frozenColumns, 0);
}
@@ -56,13 +58,13 @@
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);
-// }
+ //
+ // public String getHeight() {
+ // return (String) getStateHelper().eval(PropertyKeys.height, "");
+ // }
+ //
+ // public void setHeight(String height) {
+ // getStateHelper().put(PropertyKeys.height, height);
+ // }
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSubTable.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -5,46 +5,46 @@
import org.richfaces.component.UISubTable;
import org.richfaces.model.Ordering;
-public class HtmlSubTable extends UISubTable{
+public class HtmlSubTable extends UISubTable {
- public MethodExpression getFilterMethod() {
- return null;
- }
+ public MethodExpression getFilterMethod() {
+ return null;
+ }
- public String getFilterValue() {
- return null;
- }
+ public String getFilterValue() {
+ return null;
+ }
- public Ordering getSortOrder() {
- return null;
- }
+ public Ordering getSortOrder() {
+ return null;
+ }
- public boolean isSelfSorted() {
- return false;
- }
+ public boolean isSelfSorted() {
+ return false;
+ }
- public boolean isSortable() {
- return false;
- }
+ public boolean isSortable() {
+ return false;
+ }
- public void setFilterMethod(MethodExpression methodExpression) {
- }
+ public void setFilterMethod(MethodExpression methodExpression) {
+ }
- public void setFilterValue(String filterValue) {
- }
+ public void setFilterValue(String filterValue) {
+ }
- public void setSelfSorted(boolean selfSorted) {
- }
+ public void setSelfSorted(boolean selfSorted) {
+ }
- public void setSortOrder(Ordering sortOrder) {
- }
+ public void setSortOrder(Ordering sortOrder) {
+ }
- public void setSortable(boolean sortable) {
- }
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
+ public void setSortable(boolean sortable) {
+ }
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/DataTableState.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -12,77 +12,77 @@
/**
* @author Anton Belevich
- *
+ *
*/
public class DataTableState extends RepeatState implements StateHolder {
- private DataTableVisualModel visualModel;
-
- private Map<String, SubTableState> subTableStates = new HashMap<String,
SubTableState>();
-
- private int first;
-
- private int rows;
-
- public DataTableState(int first, int rows) {
- this.first = first;
- this.rows = rows;
- }
-
- public void setVisualModel(DataTableVisualModel visualModel) {
- this.visualModel = visualModel;
- }
-
- public DataTableVisualModel getVisualModel() {
- return this.visualModel;
- }
-
- @Override
- public int getFirst() {
- return this.first;
- }
+ private DataTableVisualModel visualModel;
- @Override
- public int getRows() {
- return this.rows;
- }
+ private Map<String, SubTableState> subTableStates = new HashMap<String,
SubTableState>();
- public void restoreState(FacesContext context, Object state) {
- Object [] newState = (Object[])state;
- if(newState != null) {
- subTableStates = (Map<String, SubTableState>)newState[0];
- }
- }
-
- public Object saveState(FacesContext context) {
- return new Object [] {subTableStates};
- }
+ private int first;
- public boolean isTransient() {
- return false;
- }
+ private int rows;
- public void setTransient(boolean newTransientValue) {
- }
+ public DataTableState(int first, int rows) {
+ this.first = first;
+ this.rows = rows;
+ }
- public void addSubTableState(SubTableState state) {
- if(state != null) {
- this.subTableStates.put(state.getId(), state);
- }
- }
-
- public SubTableState getSubTableState(String id) {
- return this.subTableStates.get(id);
- }
-
- public void addChildState(DataComponentState childState) {
- if(childState instanceof SubTableState) {
- addSubTableState((SubTableState)childState);
- }
- }
-
- public DataComponentState getChildState(String id) {
- DataComponentState state = getSubTableState(id);
- return state;
- }
+ public void setVisualModel(DataTableVisualModel visualModel) {
+ this.visualModel = visualModel;
+ }
+
+ public DataTableVisualModel getVisualModel() {
+ return this.visualModel;
+ }
+
+ @Override
+ public int getFirst() {
+ return this.first;
+ }
+
+ @Override
+ public int getRows() {
+ return this.rows;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object[] newState = (Object[]) state;
+ if (newState != null) {
+ subTableStates = (Map<String, SubTableState>) newState[0];
+ }
+ }
+
+ public Object saveState(FacesContext context) {
+ return new Object[] { subTableStates };
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ }
+
+ public void addSubTableState(SubTableState state) {
+ if (state != null) {
+ this.subTableStates.put(state.getId(), state);
+ }
+ }
+
+ public SubTableState getSubTableState(String id) {
+ return this.subTableStates.get(id);
+ }
+
+ public void addChildState(DataComponentState childState) {
+ if (childState instanceof SubTableState) {
+ addSubTableState((SubTableState) childState);
+ }
+ }
+
+ public DataComponentState getChildState(String id) {
+ DataComponentState state = getSubTableState(id);
+ return state;
+ }
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/SubTableState.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -10,70 +10,68 @@
/**
* @author Anton Belevich
- *
+ *
*/
public class SubTableState extends RepeatState implements StateHolder, ToggleListener {
-
- private SubTableVisualModel model;
-
- private String id;
-
- private int first;
-
- private int rows;
-
-
- public SubTableState(String id, int first, int rows) {
- this.id = id;
- this.first = first;
- this.rows = rows;
- }
-
- public String getId(){
- return this.id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public int getFirst() {
- return this.first;
- }
-
- @Override
- public int getRows() {
- return this.rows;
- }
-
- public SubTableVisualModel getCurrentRowModel() {
- return this.model;
- }
-
- public void setCurrentRowModel(SubTableVisualModel model) {
- this.model = model;
- }
+ private SubTableVisualModel model;
- public void restoreState(FacesContext context, Object state) {
- Object [] currentState = (Object[]) state;
- this.model = (SubTableVisualModel)currentState[0];
- }
+ private String id;
- public Object saveState(FacesContext context) {
- return new Object [] {this.model};
- }
-
- public boolean isTransient() {
- return false;
- }
-
- public void setTransient(boolean newTransientValue) {
- }
+ private int first;
- public void processToggle(ToggleEvent event) {
- boolean newValue = event.isExpanded();
- this.model.setExpanded(newValue);
- }
+ private int rows;
+
+ public SubTableState(String id, int first, int rows) {
+ this.id = id;
+ this.first = first;
+ this.rows = rows;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public int getFirst() {
+ return this.first;
+ }
+
+ @Override
+ public int getRows() {
+ return this.rows;
+ }
+
+ public SubTableVisualModel getCurrentRowModel() {
+ return this.model;
+ }
+
+ public void setCurrentRowModel(SubTableVisualModel model) {
+ this.model = model;
+ }
+
+ 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;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ }
+
+ public void processToggle(ToggleEvent event) {
+ boolean newValue = event.isExpanded();
+ this.model.setExpanded(newValue);
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/event/ToggleEvent.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/event/ToggleEvent.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/event/ToggleEvent.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -6,31 +6,30 @@
/**
* @author Anton Belevich
- *
+ *
*/
public class ToggleEvent extends FacesEvent {
- private static final long serialVersionUID = 2916560585918250885L;
+ private static final long serialVersionUID = 2916560585918250885L;
- private boolean expanded;
-
-
- public ToggleEvent(UIComponent target, boolean expanded) {
- super(target);
- this.expanded = expanded;
- }
+ private boolean expanded;
- public boolean isExpanded() {
- return this.expanded;
- }
-
- @Override
- public boolean isAppropriateListener(FacesListener listener) {
- return (listener instanceof ToggleListener);
- }
+ public ToggleEvent(UIComponent target, boolean expanded) {
+ super(target);
+ this.expanded = expanded;
+ }
- @Override
- public void processListener(FacesListener listener) {
- ((ToggleListener)listener).processToggle(this);
- }
+ public boolean isExpanded() {
+ return this.expanded;
+ }
+
+ @Override
+ public boolean isAppropriateListener(FacesListener listener) {
+ return (listener instanceof ToggleListener);
+ }
+
+ @Override
+ public void processListener(FacesListener listener) {
+ ((ToggleListener) listener).processToggle(this);
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/event/ToggleListener.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/event/ToggleListener.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/event/ToggleListener.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -4,10 +4,10 @@
/**
* @author Anton Belevich
- *
+ *
*/
public interface ToggleListener extends FacesListener {
-
- public void processToggle(ToggleEvent event);
+ public void processToggle(ToggleEvent event);
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/ColumnVisualModel.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/ColumnVisualModel.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/ColumnVisualModel.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -1,8 +1,15 @@
package org.richfaces.model.visual;
+import org.richfaces.model.Ordering;
+
/**
* @author Anton Belevich
- *
+ *
*/
public interface ColumnVisualModel {
+
+ public void setSortOrdering(Ordering sortOrder);
+
+ public Ordering getSortOder();
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/DataTableVisualModel.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/DataTableVisualModel.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/DataTableVisualModel.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -2,7 +2,7 @@
/**
* @author Anton Belevich
- *
+ *
*/
public interface DataTableVisualModel {
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/SubTableVisualModel.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/SubTableVisualModel.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/SubTableVisualModel.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -2,12 +2,12 @@
/**
* @author Anton Belevich
- *
+ *
*/
public interface SubTableVisualModel {
-
- public boolean isExpanded();
-
- public void setExpanded(boolean expand);
-
+
+ public boolean isExpanded();
+
+ public void setExpanded(boolean expand);
+
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/ColumnVisualModelImpl.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -1,12 +1,24 @@
package org.richfaces.model.visual.impl;
+import org.richfaces.model.Ordering;
import org.richfaces.model.visual.ColumnVisualModel;
/**
* @author Anton Belevich
- *
+ *
*/
public class ColumnVisualModelImpl implements ColumnVisualModel {
- public ColumnVisualModelImpl() {
- }
+
+ private Ordering sortOrder;
+
+ public ColumnVisualModelImpl() {
+ }
+
+ public Ordering getSortOder() {
+ return sortOrder;
+ }
+
+ public void setSortOrdering(Ordering sortOrder) {
+ this.sortOrder = sortOrder;
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/DataTableVisualModelImpl.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/DataTableVisualModelImpl.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/DataTableVisualModelImpl.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -4,10 +4,10 @@
/**
* @author Anton Belevich
- *
+ *
*/
-public class DataTableVisualModelImpl implements DataTableVisualModel {
-
- public DataTableVisualModelImpl() {
- }
+public class DataTableVisualModelImpl implements DataTableVisualModel {
+
+ public DataTableVisualModelImpl() {
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/SubTableVisualModelImpl.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/SubTableVisualModelImpl.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/visual/impl/SubTableVisualModelImpl.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -4,20 +4,20 @@
/**
* @author Anton Belevich
- *
+ *
*/
-public class SubTableVisualModelImpl implements SubTableVisualModel{
+public class SubTableVisualModelImpl implements SubTableVisualModel {
- private boolean expanded;
-
- public SubTableVisualModelImpl() {
- }
-
- public boolean isExpanded() {
- return this.expanded;
- }
+ private boolean expanded;
- public void setExpanded(boolean expanded) {
- this.expanded = expanded;
- }
+ public SubTableVisualModelImpl() {
+ }
+
+ public boolean isExpanded() {
+ return this.expanded;
+ }
+
+ public void setExpanded(boolean expanded) {
+ this.expanded = expanded;
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -36,50 +36,41 @@
*/
public abstract class AbstractRowsRenderer extends RendererBase implements DataVisitor {
/*
- public static final String[][] TABLE_EVENT_ATTRS = {
- //TODO nick - clarify new names for attributes
- {"onclick","onRowClick"},
- {"ondblclick","onRowDblClick"},
- {"onmousemove","onRowMouseMove"},
- {"onmouseup","onRowMouseUp"},
- {"onmousedown","onRowMouseDown"},
- {"onmouseover","onRowMouseOver"},
- {"onmouseout","onRowMouseOut"}
- };
-
+ * public static final String[][] TABLE_EVENT_ATTRS = { //TODO nick - clarify new
names for attributes
+ * {"onclick","onRowClick"},
{"ondblclick","onRowDblClick"},
{"onmousemove","onRowMouseMove"},
+ * {"onmouseup","onRowMouseUp"},
{"onmousedown","onRowMouseDown"},
{"onmouseover","onRowMouseOver"},
+ * {"onmouseout","onRowMouseOut"} };
*/
-
- public abstract void encodeRow(RowHolderBase rowHolder) throws IOException;
-
- public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
- RowHolderBase holder = (RowHolderBase) argument;
- Row row = holder.getRow();
- row.setRowKey(context, rowKey);
- try {
- encodeRow(holder);
- } catch (IOException e) {
- //TODO: seems we need add throws IOException ???
- }
- holder.nextRow();
- return DataVisitResult.CONTINUE;
- }
-
- protected void encodeRows(RowHolderBase rowHolder) throws IOException {
- rowHolder.getRow().walk(rowHolder.getContext(), this, rowHolder);
- }
- public boolean getRendersChildren() {
- return true;
- }
+ public abstract void encodeRow(RowHolderBase rowHolder) throws IOException;
- /*
- protected void encodeRowEvents(FacesContext context, UIDataAdaptor table) throws
IOException {
-
- RendererUtils utils2 = getUtils();
- for (int i = 0; i < TABLE_EVENT_ATTRS.length; i++) {
- String[] attrs = TABLE_EVENT_ATTRS[i];
- utils2.encodeAttribute(context, table, attrs[1], attrs[0]);
- }
-
- } */
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument)
{
+ RowHolderBase holder = (RowHolderBase) argument;
+ Row row = holder.getRow();
+ row.setRowKey(context, rowKey);
+ try {
+ encodeRow(holder);
+ } catch (IOException e) {
+ // TODO: seems we need add throws IOException ???
+ }
+ holder.nextRow();
+ return DataVisitResult.CONTINUE;
+ }
+
+ protected void encodeRows(RowHolderBase rowHolder) throws IOException {
+ rowHolder.getRow().walk(rowHolder.getContext(), this, rowHolder);
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ /*
+ * protected void encodeRowEvents(FacesContext context, UIDataAdaptor table) throws
IOException {
+ *
+ * RendererUtils utils2 = getUtils(); for (int i = 0; i <
TABLE_EVENT_ATTRS.length; i++) { String[] attrs =
+ * TABLE_EVENT_ATTRS[i]; utils2.encodeAttribute(context, table, attrs[1], attrs[0]);
}
+ *
+ * }
+ */
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -11,101 +11,100 @@
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTableBase;
-
-@ResourceDependencies(value = {
- @ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js")
-})
+@ResourceDependencies(value = { @ResourceDependency(library = "javax.faces",
name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"), @ResourceDependency(name =
"richfaces.js") })
public abstract class AbstractTableRenderer extends AbstractRowsRenderer {
- public boolean isColumnFacetPresent(UIDataTableBase table, String facetName) {
- Iterator<UIComponent> columns = table.columns();
- boolean result = false;
- while(columns.hasNext() && !result) {
- UIComponent component = columns.next();
- result = (component.isRendered() && null != component.getFacet(facetName));
- }
- return result;
- }
-
- /**
- * Returns true if specified attribute (when present on the column)
- * should generate header even if it is not specified on the table
- * @param table - rendered UIDataTable
- * @param attributeName - attribute name
- * @return true if specified attribute should generate header on the table
- */
- //TODO nick - rename this method
- public boolean isHeaderFactoryColumnAttributePresent(UIDataTableBase table,String
attributeName) {
+ public boolean isColumnFacetPresent(UIDataTableBase table, String facetName) {
Iterator<UIComponent> columns = table.columns();
boolean result = false;
while (columns.hasNext() && !result) {
UIComponent component = columns.next();
- result = (component.isRendered() && (null !=
component.getValueExpression(attributeName)));
+ result = (component.isRendered() && null !=
component.getFacet(facetName));
}
return result;
}
-
- protected boolean isEncodeHeaders(UIDataTableBase table) {
- return isColumnFacetPresent(table, "header") ||
- isHeaderFactoryColumnAttributePresent(table, "sortBy") ||
- isHeaderFactoryColumnAttributePresent(table, "comparator") ||
- isHeaderFactoryColumnAttributePresent(table, "filterBy");
- }
-
- protected int getColumnsCount(UIDataTableBase table) {
- // check for exact value in component
- Integer span = (Integer) table.getAttributes().get("columns");
- int count = (null != span && span.intValue() != Integer.MIN_VALUE) ?
span.intValue() : calculateRowColumns(table.columns());
- return count;
- }
-
- //TODO nick - rename method
- protected int calculateRowColumns(Iterator<UIComponent> col) {
- int count = 0;
- int currentLength = 0;
- while (col.hasNext()) {
- UIComponent component = (UIComponent) col.next();
- if (component.isRendered()) {
- if (component instanceof Row) {
- // Store max calculated value of previsous rows.
- if (currentLength > count) {
- count = currentLength;
- }
- // Calculate number of columns in row.
- currentLength = calculateRowColumns(((Row) component).columns());
- // Store max calculated value
- if (currentLength > count) {
- count = currentLength;
- }
- currentLength = 0;
- } else if (component instanceof Column) {
- Column column = (Column) component;
- // For new row, save length of previsous.
- if (column.isBreakBefore()) {
- if (currentLength > count) {
- count = currentLength;
- }
- currentLength = 0;
- }
- Integer colspan = (Integer) component.getAttributes().get("colspan");
- // Append colspan of this column
- if (null != colspan && colspan.intValue() != Integer.MIN_VALUE) {
- currentLength += colspan.intValue();
- } else {
- currentLength++;
- }
- } else if (component instanceof UIColumn) {
- // UIColumn always have colspan == 1.
- currentLength++;
- }
- }
- }
-
- if (currentLength > count) {
- count = currentLength;
- }
- return count;
- }
+
+ /**
+ * Returns true if specified attribute (when present on the column) should generate
header even if it is not
+ * specified on the table
+ *
+ * @param table
+ * - rendered UIDataTable
+ * @param attributeName
+ * - attribute name
+ * @return true if specified attribute should generate header on the table
+ */
+ // TODO nick - rename this method
+ public boolean isHeaderFactoryColumnAttributePresent(UIDataTableBase table, String
attributeName) {
+ Iterator<UIComponent> columns = table.columns();
+ boolean result = false;
+ while (columns.hasNext() && !result) {
+ UIComponent component = columns.next();
+ result = (component.isRendered() && (null !=
component.getValueExpression(attributeName)));
+ }
+ return result;
+ }
+
+ protected boolean isEncodeHeaders(UIDataTableBase table) {
+ return isColumnFacetPresent(table, "header") ||
isHeaderFactoryColumnAttributePresent(table, "sortBy")
+ || isHeaderFactoryColumnAttributePresent(table, "comparator")
+ || isHeaderFactoryColumnAttributePresent(table, "filterBy");
+ }
+
+ protected int getColumnsCount(UIDataTableBase table) {
+ // check for exact value in component
+ Integer span = (Integer) table.getAttributes().get("columns");
+ int count = (null != span && span.intValue() != Integer.MIN_VALUE) ?
span.intValue()
+ : calculateRowColumns(table.columns());
+ return count;
+ }
+
+ // TODO nick - rename method
+ protected int calculateRowColumns(Iterator<UIComponent> col) {
+ int count = 0;
+ int currentLength = 0;
+ while (col.hasNext()) {
+ UIComponent component = (UIComponent) col.next();
+ if (component.isRendered()) {
+ if (component instanceof Row) {
+ // Store max calculated value of previsous rows.
+ if (currentLength > count) {
+ count = currentLength;
+ }
+ // Calculate number of columns in row.
+ currentLength = calculateRowColumns(((Row) component).columns());
+ // Store max calculated value
+ if (currentLength > count) {
+ count = currentLength;
+ }
+ currentLength = 0;
+ } else if (component instanceof Column) {
+ Column column = (Column) component;
+ // For new row, save length of previsous.
+ if (column.isBreakBefore()) {
+ if (currentLength > count) {
+ count = currentLength;
+ }
+ currentLength = 0;
+ }
+ Integer colspan = (Integer)
component.getAttributes().get("colspan");
+ // Append colspan of this column
+ if (null != colspan && colspan.intValue() !=
Integer.MIN_VALUE) {
+ currentLength += colspan.intValue();
+ } else {
+ currentLength++;
+ }
+ } else if (component instanceof UIColumn) {
+ // UIColumn always have colspan == 1.
+ currentLength++;
+ }
+ }
+ }
+
+ if (currentLength > count) {
+ count = currentLength;
+ }
+ return count;
+ }
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -16,598 +16,603 @@
import org.richfaces.component.UIDataTable;
import org.richfaces.component.UISubTable;
-@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")
-})
-public class DataTableRenderer extends AbstractTableRenderer implements
ElementEncodeListener{
-
- @Override
- protected void doDecode(FacesContext context, UIComponent component) {
- System.out.println("DataTableRenderer.doDecode()");
- }
-
- protected void encodeTableStructure(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable) throws IOException {
-
- Object key = dataTable.getRowKey();
- dataTable.captureOrigValue(context);
- dataTable.setRowKey(context, null);
-
- if(dataTable instanceof UIDataTable) {
- encodeCaption(writer, context, (UIDataTable)dataTable);
- //TODO nick - do we need this element if "columnsWidth" is absent?
- //TODO nick - use constants from HTML class for attribute/element names
- writer.startElement("colgroup", dataTable);
- int columns = getColumnsCount(dataTable);
+@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") })
+public class DataTableRenderer extends AbstractTableRenderer implements
ElementEncodeListener {
- writer.writeAttribute(HTML.SPAN_ELEM, String.valueOf(columns), null);
- String columnsWidth = (String)
dataTable.getAttributes().get("columnsWidth");
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ System.out.println("DataTableRenderer.doDecode()");
+ }
- if (null != columnsWidth) {
- String[] widths = columnsWidth.split(",");
- for (int i = 0; i < widths.length; i++) {
- writer.startElement("col", dataTable);
- writer.writeAttribute("width", widths[i], null);
- writer.endElement("col");
- }
- }
- writer.endElement("colgroup");
-
- }
+ protected void encodeTableStructure(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable)
+ throws IOException {
- encodeHeader(writer, context, dataTable);
- encodeFooter(writer, context, dataTable);
+ Object key = dataTable.getRowKey();
+ dataTable.captureOrigValue(context);
+ dataTable.setRowKey(context, null);
- dataTable.setRowKey(context, key);
- dataTable.restoreOrigValue(context);
- }
-
-
- public void encodeRows(FacesContext context, UIDataTableBase dataTable) throws
IOException {
-
- RowHolder holder = new RowHolder(context, dataTable);
- holder.setCellClass(dataTable.getCellSkinClass());
- holder.setRowClass(dataTable.getRowSkinClass());
- holder.setFirstRowClass(dataTable.getFirstRowSkinClass());
- holder.setHeaderRow(false);
- holder.setCellElement(HTML.TD_ELEM);
-
- encodeRows(holder);
- }
- //TODO: refactor
- public void encodeRow(RowHolderBase holder) throws IOException {
- FacesContext context = holder.getContext();
- RowHolder rowHolder = (RowHolder) holder;
- boolean rowStart = true;
- boolean bodyStart = false;
-
-
- int processCell = 0;
-
- Row row = rowHolder.getRow();
- int processRow = rowHolder.getCurrentRow();
-
- ResponseWriter writer = context.getResponseWriter();
-
- if(rowHolder.isDataTable()) {
- encodeTableBodyStart(writer, context, (UIDataTable)row);
- bodyStart = true;
- }
-
- Iterator<UIComponent> iterator = row.columns();
- while(iterator.hasNext()) {
-
- UIComponent child = iterator.next();
- if(child instanceof Row) {
-
- Row childRow = (Row)child;
- RowHolder childRowHolder = new RowHolder(context, childRow);
- childRowHolder.setCurrentRow(processRow);
- childRowHolder.setCellElement(rowHolder.getCellElement());
-
- if(rowHolder.isHeaderRow()) {
- childRowHolder.setRowClass(rowHolder.getRowClass());
- childRowHolder.setFirstRowClass(rowHolder.getFirstRowClass());
- childRowHolder.setCellClass(rowHolder.getCellClass());
- childRowHolder.setCellElement(HTML.TH_ELEM);
- } else {
- childRowHolder.setRowClass(childRow.getRowSkinClass());
- childRowHolder.setFirstRowClass(childRow.getFirstRowSkinClass());
- childRowHolder.setCellClass(childRow.getCellSkinClass());
- childRowHolder.setCellElement(HTML.TD_ELEM);
- }
- childRowHolder.setHeaderRow(rowHolder.isHeaderRow());
-
- if(child instanceof UISubTable) {
- //ecode subTable header facet
- UISubTable subTable = (UISubTable)child;
-
- if(bodyStart) {
- encodeTableBodyEnd(writer, context, (UIDataTableBase)row);
- bodyStart = false;
- }
-// subTable.setRowKey(childRowHolder.getCurrentRow());
-
-/* Object key = subTable.getRowKey();
- subTable.captureOrigValue(context);
- subTable.setRowKey(context, null); */
+ if (dataTable instanceof UIDataTable) {
+ encodeCaption(writer, context, (UIDataTable) dataTable);
+ // TODO nick - do we need this element if "columnsWidth" is
absent?
+ // TODO nick - use constants from HTML class for attribute/element names
+ writer.startElement("colgroup", dataTable);
+ int columns = getColumnsCount(dataTable);
-
- encodeTableBodyStart(writer, context, subTable);
- encodeHeader(writer, context, subTable);
-
- encodeRows(childRowHolder);
-
- encodeFooter(writer, context, subTable);
-
-/* subTable.setRowKey(context, key);
- subTable.restoreOrigValue(context); */
+ writer.writeAttribute(HTML.SPAN_ELEM, String.valueOf(columns), null);
+ String columnsWidth = (String)
dataTable.getAttributes().get("columnsWidth");
-// encodeHiddenInput(context, writer, subTable);
+ if (null != columnsWidth) {
+ String[] widths = columnsWidth.split(",");
+ for (int i = 0; i < widths.length; i++) {
+ writer.startElement("col", dataTable);
+ writer.writeAttribute("width", widths[i], null);
+ writer.endElement("col");
+ }
+ }
+ writer.endElement("colgroup");
- encodeTableBodyEnd(writer, context, subTable);
-
- bodyStart = false;
- if(iterator.hasNext()) {
- encodeTableBodyStart(writer, context, (UIDataTableBase)row);
- bodyStart=true;
- }
-
- } else {
- encodeRows(childRowHolder);
- }
-
- } else if(child instanceof UIColumn) {
-
- if(child instanceof org.richfaces.component.UIColumn) {
- org.richfaces.component.UIColumn column = (org.richfaces.component.UIColumn)child;
- if(column.isBreakBefore() && processCell !=0) {
- encodeRowEnd(writer, context, column);
- rowHolder.nextRow();
- rowStart = true;
- }
- }
-
- if(rowStart) {
- if(processRow == 0) {
- encodeFirstRowStart(writer, context, child, rowHolder);
- } else {
- encodeRowStart(writer, context, child, rowHolder);
- }
-
- rowStart = false;
- }
-
- encodeCellStart(writer, context, child, rowHolder);
- encodeCellEnd(writer, context, child, rowHolder);
-
- if(!iterator.hasNext()) {
- if(processRow == 0) {
- encodeFirstRowEnd(writer, context, child);
- } else {
- encodeRowEnd(writer, context, child);
- }
- }
- processCell++;
- }
- }
-
- if(bodyStart && rowHolder.isDataTable()) {
- encodeTableBodyEnd(writer, context, (UIDataTableBase) row);
- }
- }
-/*
- public void encodeHiddenInput(FacesContext context, ResponseWriter writer,
UIDataTableBase dataTable) throws IOException {
-
- String hiddenId = dataTable.getClientId(context) + ":" + "hidden";
-
- writer.startElement(HTML.INPUT_ELEM, dataTable);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, hiddenId, null);
- writer.writeAttribute(HTML.TYPE_ATTR,"hidden", null);
- writer.endElement(HTML.INPUT_ELEM);
-
- } */
-
- @Override
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- if(!shouldProceed(component)) {
- return;
- }
- UIDataTableBase dataTable = (UIDataTableBase)component;
- encodeTableStart(writer,context, dataTable);
- encodeTableStructure(writer, context, dataTable);
- }
-
- @Override
- protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
-
- if(!shouldProceed(component)) {
- return;
- }
-
- UIDataTableBase dataTable = (UIDataTableBase)component;
-// encodeTableBodyStart(writer, context, dataTable);
- encodeRows(context, dataTable);
-// encodeTableBodyEnd(writer, context, dataTable);
-
- }
-
- @Override
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
-
- if(!shouldProceed(component)) {
- return;
- }
-
- UIDataTableBase dataTable = (UIDataTableBase)component;
- encodeTableEnd(writer, context, dataTable);
- }
-
- protected boolean shouldProceed(UIComponent component) {
- return (component instanceof UIDataTableBase);
- }
+ }
- @Override
- protected Class<? extends UIComponent> getComponentClass() {
- return UIDataTable.class;
- }
+ encodeHeader(writer, context, dataTable);
+ encodeFooter(writer, context, dataTable);
- public void encodeCellEnd(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder) throws IOException {
- writer.endElement(holder.getCellElement());
- }
+ dataTable.setRowKey(context, key);
+ dataTable.restoreOrigValue(context);
+ }
- public void encodeCellStart(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder) throws IOException {
- //anton - TODO: scope attribute
- writer.startElement(holder.getCellElement(), component);
- String cellClass = holder.getCellClass();
- encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, cellClass);
-
- if(component instanceof org.richfaces.component.UIColumn) {
- org.richfaces.component.UIColumn column =
(org.richfaces.component.UIColumn)component;
-
- int rowspan = column.getRowspan();
- if(rowspan != Integer.MIN_VALUE) {
- writer.writeAttribute("rowspan", Integer.valueOf(rowspan), null);
- }
-
- int colspan = column.getColspan();
- if(colspan != Integer.MIN_VALUE) {
- writer.writeAttribute("colspan", Integer.valueOf(colspan), null);
- }
- }
- renderChildren(context, component);
- }
+ public void encodeRows(FacesContext context, UIDataTableBase dataTable) throws
IOException {
- public void encodeFirstRowEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- writer.endElement(HTML.TR_ELEMENT);
- }
+ RowHolder holder = new RowHolder(context, dataTable);
+ holder.setCellClass(dataTable.getCellSkinClass());
+ holder.setRowClass(dataTable.getRowSkinClass());
+ holder.setFirstRowClass(dataTable.getFirstRowSkinClass());
+ holder.setHeaderRow(false);
+ holder.setCellElement(HTML.TD_ELEM);
- public void encodeFirstRowStart(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder) throws IOException {
- writer.startElement(HTML.TR_ELEMENT, component);
- getUtils().encodeId(context, component);
- String styleClass = holder.getRowClass() + " " +
holder.getFirstRowClass();
- encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
- }
+ encodeRows(holder);
+ }
- public void encodeRowEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- writer.endElement(HTML.TR_ELEMENT);
- }
+ // TODO: refactor
+ public void encodeRow(RowHolderBase holder) throws IOException {
+ FacesContext context = holder.getContext();
+ RowHolder rowHolder = (RowHolder) holder;
+ boolean rowStart = true;
+ boolean bodyStart = false;
- public void encodeRowStart(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder) throws IOException {
- writer.startElement(HTML.TR_ELEMENT, component);
- getUtils().encodeId(context, component);
- String styleClass = holder.getRowClass();
- encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
- }
+ int processCell = 0;
- public void encodeTableBodyEnd(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException {
- writer.endElement(HTML.TBOBY_ELEMENT);
- }
+ Row row = rowHolder.getRow();
+ int processRow = rowHolder.getCurrentRow();
- public void encodeTableBodyStart(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException {
- writer.startElement(HTML.TBOBY_ELEMENT, component);
- getUtils().encodeId(context, component);
-
- String predefinedStyles = null;
- if(component instanceof UISubTable) {
- UISubTable subTable = (UISubTable)component;
- if(!subTable.isExpanded()) {
- predefinedStyles = "display: none;";
- }
- }
-
- encodeStyle(writer, context, component, predefinedStyles);
- }
+ ResponseWriter writer = context.getResponseWriter();
- public void encodeTableEnd(ResponseWriter writer, FacesContext context, UIDataTableBase
component) throws IOException {
- writer.endElement(HTML.TABLE_ELEMENT);
- }
+ if (rowHolder.isDataTable()) {
+ encodeTableBodyStart(writer, context, (UIDataTable) row);
+ bodyStart = true;
+ }
- public void encodeTableStart(ResponseWriter writer, FacesContext context,
UIDataTableBase component) throws IOException {
- writer.startElement(HTML.TABLE_ELEMENT, component);
- String styleClass = getTableSkinClass();
- encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
- }
+ Iterator<UIComponent> iterator = row.columns();
+ while (iterator.hasNext()) {
- public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTable
dataTable) throws IOException {
-
- UIComponent caption = dataTable.getCaption();
-
- if (caption == null) {
- return;
- }
-
- if(!caption.isRendered()) {
- return;
- }
-
- writer.startElement(HTML.CAPTION_ELEMENT, dataTable);
+ UIComponent child = iterator.next();
+ if (child instanceof Row) {
- String captionClass = (String)
dataTable.getAttributes().get("captionClass");
- String captionSkinClass = getCaptionSkinClass();
- captionClass = captionClass != null ? captionClass + " " + captionClass :
captionSkinClass;
-
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, captionClass, "captionClass");
+ Row childRow = (Row) child;
+ RowHolder childRowHolder = new RowHolder(context, childRow);
+ childRowHolder.setCurrentRow(processRow);
+ childRowHolder.setCellElement(rowHolder.getCellElement());
- String captionStyle = (String)
dataTable.getAttributes().get("captionStyle");
-
- if (captionStyle != null && captionStyle.trim().length()!=0) {
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, captionStyle, "captionStyle");
- }
+ if (rowHolder.isHeaderRow()) {
+ childRowHolder.setRowClass(rowHolder.getRowClass());
+ childRowHolder.setFirstRowClass(rowHolder.getFirstRowClass());
+ childRowHolder.setCellClass(rowHolder.getCellClass());
+ childRowHolder.setCellElement(HTML.TH_ELEM);
+ } else {
+ childRowHolder.setRowClass(childRow.getRowSkinClass());
+ childRowHolder.setFirstRowClass(childRow.getFirstRowSkinClass());
+ childRowHolder.setCellClass(childRow.getCellSkinClass());
+ childRowHolder.setCellElement(HTML.TD_ELEM);
+ }
+ childRowHolder.setHeaderRow(rowHolder.isHeaderRow());
- renderChild(context, caption);
-
- writer.endElement(HTML.CAPTION_ELEMENT);
- }
-
- public void encodeFooter(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException {
+ if (child instanceof UISubTable) {
+ // ecode subTable header facet
+ UISubTable subTable = (UISubTable) child;
- Iterator<UIComponent> tableColumns = dataTable.columns();
-
- UIComponent footer = dataTable.getFooter();
- boolean columnFacetPresent = isColumnFacetPresent(dataTable, "footer");
-
- if ((footer != null && footer.isRendered()) || columnFacetPresent) {
- boolean encodeTfoot = (dataTable instanceof UIDataTable);
- String cellElement = HTML.TD_ELEM;
-
- if(encodeTfoot) {
- writer.startElement(HTML.TFOOT_ELEMENT, dataTable);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-tfoot", null);
- cellElement = HTML.TH_ELEM;
- }
-
- String footerClass = (String) dataTable.getAttributes().get("footerClass");
- int columns = getColumnsCount(dataTable);
+ if (bodyStart) {
+ encodeTableBodyEnd(writer, context, (UIDataTableBase) row);
+ bodyStart = false;
+ }
+ // subTable.setRowKey(childRowHolder.getCurrentRow());
- if (columnFacetPresent) {
- writer.startElement(HTML.TR_ELEMENT, dataTable);
-
- encodeStyleClass(writer, context, dataTable, "footerClass",
dataTable.getColumnFooterSkinClass());
- //TODO nick - rename method "encodeHeaderFacets"
- encodeHeaderFacets(context, writer, tableColumns,
dataTable.getColumnFooterCellSkinClass(),
- footerClass, "footer", cellElement, columns);
- writer.endElement(HTML.TR_ELEMENT);
- }
-
- if (footer != null && footer.isRendered()) {
- //TODO nick - rename method "encodeTableHeaderFacet"
- encodeTableHeaderFacet(context, columns, writer, footer,
- dataTable.getFooterFirstRowSkinClass(),
- dataTable.getFooterRowSkinClass(),
- dataTable.getFooterCellSkinClass(),
- footerClass, cellElement);
- }
-
- if(encodeTfoot) {
- writer.endElement(HTML.TFOOT_ELEMENT);
- }
- }
-
- }
+ /*
+ * Object key = subTable.getRowKey();
subTable.captureOrigValue(context);
+ * subTable.setRowKey(context, null);
+ */
- public void encodeHeader(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException {
-
- UIComponent header = dataTable.getHeader();
- boolean isEncodeHeaders = isEncodeHeaders(dataTable);
-
- boolean encodeThead = (dataTable instanceof UIDataTable);
-
- if ((header != null && header.isRendered()) || isEncodeHeaders) {
-
- String cellElement = HTML.TD_ELEM;
-
- if(encodeThead) {
- writer.startElement(HTML.THEAD_ELEMENT, dataTable);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-thead", null);
- cellElement = HTML.TH_ELEM;
-
- }
- // TODO anton - maybe we should have separate css class for column header???
- String headerClass = (String) dataTable.getAttributes().get("headerClass");
+ encodeTableBodyStart(writer, context, subTable);
+ encodeHeader(writer, context, subTable);
- int columns = getColumnsCount(dataTable);
+ encodeRows(childRowHolder);
- if (header != null && header.isRendered()) {
-
- encodeTableHeaderFacet(context, columns, writer, header,
- dataTable.getHeaderFirstRowSkinClass(),
- dataTable.getHeaderRowSkinClass(),
- dataTable.getHeaderCellSkinClass(),
-// "rich-table-header",
- //TODO nick - rename classes!!!
-// "rich-table-header-continue",
-// "rich-table-headercell",
- headerClass, cellElement);
- }
+ encodeFooter(writer, context, subTable);
- if (isEncodeHeaders) {
- writer.startElement(HTML.TR_ELEMENT, dataTable);
- encodeStyleClass(writer, context, dataTable, "headerClass",
dataTable.getColumnHeaderSkinClass());//"rich-table-subheader");
- encodeHeaderFacets(context, writer, dataTable.columns(),
dataTable.getColumnHeaderCellSkinClass()/*"rich-table-subheadercell"*/,
headerClass, "header", cellElement, columns);
- writer.endElement(HTML.TR_ELEMENT);
- }
-
- if(encodeThead) {
- writer.endElement(HTML.THEAD_ELEMENT);
- }
- }
-
- }
-
+ /*
+ * subTable.setRowKey(context, key);
subTable.restoreOrigValue(context);
+ */
+
+ // encodeHiddenInput(context, writer, subTable);
+ encodeTableBodyEnd(writer, context, subTable);
+
+ bodyStart = false;
+ if (iterator.hasNext()) {
+ encodeTableBodyStart(writer, context, (UIDataTableBase) row);
+ bodyStart = true;
+ }
+
+ } else {
+ encodeRows(childRowHolder);
+ }
+
+ } else if (child instanceof UIColumn) {
+
+ if (child instanceof org.richfaces.component.UIColumn) {
+ org.richfaces.component.UIColumn column =
(org.richfaces.component.UIColumn) child;
+ if (column.isBreakBefore() && processCell != 0) {
+ encodeRowEnd(writer, context, column);
+ rowHolder.nextRow();
+ rowStart = true;
+ }
+ }
+
+ if (rowStart) {
+ if (processRow == 0) {
+ encodeFirstRowStart(writer, context, child, rowHolder);
+ } else {
+ encodeRowStart(writer, context, child, rowHolder);
+ }
+
+ rowStart = false;
+ }
+
+ encodeCellStart(writer, context, child, rowHolder);
+ encodeCellEnd(writer, context, child, rowHolder);
+
+ if (!iterator.hasNext()) {
+ if (processRow == 0) {
+ encodeFirstRowEnd(writer, context, child);
+ } else {
+ encodeRowEnd(writer, context, child);
+ }
+ }
+ processCell++;
+ }
+ }
+
+ if (bodyStart && rowHolder.isDataTable()) {
+ encodeTableBodyEnd(writer, context, (UIDataTableBase) row);
+ }
+ }
+
+ /*
+ * public void encodeHiddenInput(FacesContext context, ResponseWriter writer,
UIDataTableBase dataTable) throws
+ * IOException {
+ *
+ * String hiddenId = dataTable.getClientId(context) + ":" +
"hidden";
+ *
+ * writer.startElement(HTML.INPUT_ELEM, dataTable);
writer.writeAttribute(HTML.ID_ATTRIBUTE, hiddenId, null);
+ * writer.writeAttribute(HTML.TYPE_ATTR,"hidden", null);
writer.endElement(HTML.INPUT_ELEM);
+ *
+ * }
+ */
+
+ @Override
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ if (!shouldProceed(component)) {
+ return;
+ }
+ UIDataTableBase dataTable = (UIDataTableBase) component;
+ encodeTableStart(writer, context, dataTable);
+ encodeTableStructure(writer, context, dataTable);
+ }
+
+ @Override
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context,
UIComponent component)
+ throws IOException {
+
+ if (!shouldProceed(component)) {
+ return;
+ }
+
+ UIDataTableBase dataTable = (UIDataTableBase) component;
+ // encodeTableBodyStart(writer, context, dataTable);
+ encodeRows(context, dataTable);
+ // encodeTableBodyEnd(writer, context, dataTable);
+
+ }
+
+ @Override
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+
+ if (!shouldProceed(component)) {
+ return;
+ }
+
+ UIDataTableBase dataTable = (UIDataTableBase) component;
+ encodeTableEnd(writer, context, dataTable);
+ }
+
+ protected boolean shouldProceed(UIComponent component) {
+ return (component instanceof UIDataTableBase);
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIDataTable.class;
+ }
+
+ public void encodeCellEnd(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder)
+ throws IOException {
+ writer.endElement(holder.getCellElement());
+ }
+
+ public void encodeCellStart(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder)
+ throws IOException {
+ // anton - TODO: scope attribute
+ writer.startElement(holder.getCellElement(), component);
+ String cellClass = holder.getCellClass();
+ encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, cellClass);
+
+ if (component instanceof org.richfaces.component.UIColumn) {
+ org.richfaces.component.UIColumn column = (org.richfaces.component.UIColumn)
component;
+
+ int rowspan = column.getRowspan();
+ if (rowspan != Integer.MIN_VALUE) {
+ writer.writeAttribute("rowspan", Integer.valueOf(rowspan),
null);
+ }
+
+ int colspan = column.getColspan();
+ if (colspan != Integer.MIN_VALUE) {
+ writer.writeAttribute("colspan", Integer.valueOf(colspan),
null);
+ }
+ }
+ renderChildren(context, component);
+ }
+
+ public void encodeFirstRowEnd(ResponseWriter writer, FacesContext context,
UIComponent component)
+ throws IOException {
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ public void encodeFirstRowStart(ResponseWriter writer, FacesContext context,
UIComponent component, RowHolder holder)
+ throws IOException {
+ writer.startElement(HTML.TR_ELEMENT, component);
+ getUtils().encodeId(context, component);
+ String styleClass = holder.getRowClass() + " " +
holder.getFirstRowClass();
+ encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
+ }
+
+ public void encodeRowEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ public void encodeRowStart(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder)
+ throws IOException {
+ writer.startElement(HTML.TR_ELEMENT, component);
+ getUtils().encodeId(context, component);
+ String styleClass = holder.getRowClass();
+ encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
+ }
+
+ public void encodeTableBodyEnd(ResponseWriter writer, FacesContext context,
UIDataTableBase component)
+ throws IOException {
+ writer.endElement(HTML.TBOBY_ELEMENT);
+ }
+
+ public void encodeTableBodyStart(ResponseWriter writer, FacesContext context,
UIDataTableBase component)
+ throws IOException {
+ writer.startElement(HTML.TBOBY_ELEMENT, component);
+ getUtils().encodeId(context, component);
+
+ String predefinedStyles = null;
+ if (component instanceof UISubTable) {
+ UISubTable subTable = (UISubTable) component;
+ if (!subTable.isExpanded()) {
+ predefinedStyles = "display: none;";
+ }
+ }
+
+ encodeStyle(writer, context, component, predefinedStyles);
+ }
+
+ public void encodeTableEnd(ResponseWriter writer, FacesContext context,
UIDataTableBase component)
+ throws IOException {
+ writer.endElement(HTML.TABLE_ELEMENT);
+ }
+
+ public void encodeTableStart(ResponseWriter writer, FacesContext context,
UIDataTableBase component)
+ throws IOException {
+ writer.startElement(HTML.TABLE_ELEMENT, component);
+ String styleClass = getTableSkinClass();
+ encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
+ }
+
+ public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTable
dataTable) throws IOException {
+
+ UIComponent caption = dataTable.getCaption();
+
+ if (caption == null) {
+ return;
+ }
+
+ if (!caption.isRendered()) {
+ return;
+ }
+
+ writer.startElement(HTML.CAPTION_ELEMENT, dataTable);
+
+ String captionClass = (String)
dataTable.getAttributes().get("captionClass");
+ String captionSkinClass = getCaptionSkinClass();
+ captionClass = captionClass != null ? captionClass + " " + captionClass
: captionSkinClass;
+
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, captionClass,
"captionClass");
+
+ String captionStyle = (String)
dataTable.getAttributes().get("captionStyle");
+
+ if (captionStyle != null && captionStyle.trim().length() != 0) {
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, captionStyle,
"captionStyle");
+ }
+
+ renderChild(context, caption);
+
+ writer.endElement(HTML.CAPTION_ELEMENT);
+ }
+
+ public void encodeFooter(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException {
+
+ Iterator<UIComponent> tableColumns = dataTable.columns();
+
+ UIComponent footer = dataTable.getFooter();
+ boolean columnFacetPresent = isColumnFacetPresent(dataTable,
"footer");
+
+ if ((footer != null && footer.isRendered()) || columnFacetPresent) {
+ boolean encodeTfoot = (dataTable instanceof UIDataTable);
+ String cellElement = HTML.TD_ELEM;
+
+ if (encodeTfoot) {
+ writer.startElement(HTML.TFOOT_ELEMENT, dataTable);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-tfoot",
null);
+ cellElement = HTML.TH_ELEM;
+ }
+
+ String footerClass = (String)
dataTable.getAttributes().get("footerClass");
+ int columns = getColumnsCount(dataTable);
+
+ if (columnFacetPresent) {
+ writer.startElement(HTML.TR_ELEMENT, dataTable);
+
+ encodeStyleClass(writer, context, dataTable, "footerClass",
dataTable.getColumnFooterSkinClass());
+ // TODO nick - rename method "encodeHeaderFacets"
+ encodeHeaderFacets(context, writer, tableColumns,
dataTable.getColumnFooterCellSkinClass(),
+ footerClass, "footer", cellElement, columns);
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ if (footer != null && footer.isRendered()) {
+ // TODO nick - rename method "encodeTableHeaderFacet"
+ encodeTableHeaderFacet(context, columns, writer, footer,
dataTable.getFooterFirstRowSkinClass(),
+ dataTable.getFooterRowSkinClass(),
dataTable.getFooterCellSkinClass(), footerClass, cellElement);
+ }
+
+ if (encodeTfoot) {
+ writer.endElement(HTML.TFOOT_ELEMENT);
+ }
+ }
+
+ }
+
+ public void encodeHeader(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException {
+
+ UIComponent header = dataTable.getHeader();
+ boolean isEncodeHeaders = isEncodeHeaders(dataTable);
+
+ boolean encodeThead = (dataTable instanceof UIDataTable);
+
+ if ((header != null && header.isRendered()) || isEncodeHeaders) {
+
+ String cellElement = HTML.TD_ELEM;
+
+ if (encodeThead) {
+ writer.startElement(HTML.THEAD_ELEMENT, dataTable);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-thead",
null);
+ cellElement = HTML.TH_ELEM;
+
+ }
+ // TODO anton - maybe we should have separate css class for column header???
+ String headerClass = (String)
dataTable.getAttributes().get("headerClass");
+
+ int columns = getColumnsCount(dataTable);
+
+ if (header != null && header.isRendered()) {
+
+ encodeTableHeaderFacet(context, columns, writer, header,
dataTable.getHeaderFirstRowSkinClass(),
+ dataTable.getHeaderRowSkinClass(),
dataTable.getHeaderCellSkinClass(),
+ // "rich-table-header",
+ // TODO nick - rename classes!!!
+ // "rich-table-header-continue",
+ // "rich-table-headercell",
+ headerClass, cellElement);
+ }
+
+ if (isEncodeHeaders) {
+ writer.startElement(HTML.TR_ELEMENT, dataTable);
+ encodeStyleClass(writer, context, dataTable, "headerClass",
dataTable.getColumnHeaderSkinClass());// "rich-table-subheader");
+ encodeHeaderFacets(context, writer, dataTable.columns(),
+ dataTable.getColumnHeaderCellSkinClass()/*
"rich-table-subheadercell" */, headerClass, "header",
+ cellElement, columns);
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ if (encodeThead) {
+ writer.endElement(HTML.THEAD_ELEMENT);
+ }
+ }
+
+ }
+
protected void encodeTableHeaderFacet(FacesContext context, int columns,
ResponseWriter writer, UIComponent footer,
- String skinFirstRowClass, String skinRowClass, String skinCellClass, String
footerClass, String element)
- throws IOException {
-
- if(footer instanceof Row) {
- Row row = (Row)footer;
-
- RowHolder holder = new RowHolder(context, row);
- holder.setCellElement(element);
- holder.setFirstRowClass(skinFirstRowClass);
- holder.setRowClass(skinRowClass);
- holder.setCellClass(skinCellClass);
- //holder.resetCurrentRow();
- holder.setHeaderRow(true);
-
- encodeRows(holder);
-
- } else {
- writer.startElement(HTML.TR_ELEMENT, footer);
-
- String rowClass = skinFirstRowClass;
- String cellClass = skinCellClass;
- if(footerClass != null && footerClass.trim().length()!=0) {
- rowClass = rowClass + " " + footerClass;
- cellClass = cellClass + " " + footerClass;
- }
-
- encodeStyleClass(writer, context, footer, null, rowClass);
-
- writer.startElement(element, footer);
-
- encodeStyleClass(writer, context, footer, null, cellClass);
-
- if(columns > 0) {
- writer.writeAttribute("colspan", String.valueOf(columns), null);
- }
-
- writer.writeAttribute("scope", "colgroup", null);
-
- renderChild(context, footer);
-
- writer.endElement(element);
- writer.endElement(HTML.TR_ELEMENT);
- }
+ String skinFirstRowClass, String skinRowClass, String skinCellClass, String
footerClass, String element)
+ throws IOException {
+
+ if (footer instanceof Row) {
+ Row row = (Row) footer;
+
+ RowHolder holder = new RowHolder(context, row);
+ holder.setCellElement(element);
+ holder.setFirstRowClass(skinFirstRowClass);
+ holder.setRowClass(skinRowClass);
+ holder.setCellClass(skinCellClass);
+ // holder.resetCurrentRow();
+ holder.setHeaderRow(true);
+
+ encodeRows(holder);
+
+ } else {
+ writer.startElement(HTML.TR_ELEMENT, footer);
+
+ String rowClass = skinFirstRowClass;
+ String cellClass = skinCellClass;
+ if (footerClass != null && footerClass.trim().length() != 0) {
+ rowClass = rowClass + " " + footerClass;
+ cellClass = cellClass + " " + footerClass;
+ }
+
+ encodeStyleClass(writer, context, footer, null, rowClass);
+
+ writer.startElement(element, footer);
+
+ encodeStyleClass(writer, context, footer, null, cellClass);
+
+ if (columns > 0) {
+ writer.writeAttribute("colspan", String.valueOf(columns),
null);
+ }
+
+ writer.writeAttribute("scope", "colgroup", null);
+
+ renderChild(context, footer);
+
+ writer.endElement(element);
+ writer.endElement(HTML.TR_ELEMENT);
+ }
}
protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer,
Iterator<UIComponent> headers,
- String skinCellClass, String headerClass, String facetName, String element,
int colCount) throws IOException {
-
- int tColCount = 0;
+ String skinCellClass, String headerClass, String facetName, String element, int
colCount) throws IOException {
- while (headers.hasNext()) {
- UIComponent column = headers.next();
- if (!column.isRendered()) {
- continue;
- }
+ int tColCount = 0;
- Integer colspan = (Integer) column.getAttributes().get("colspan");
- if (colspan != null && colspan.intValue() > 0) {
- tColCount += colspan.intValue();
- } else {
- tColCount++;
- }
+ while (headers.hasNext()) {
+ UIComponent column = headers.next();
+ if (!column.isRendered()) {
+ continue;
+ }
- if (tColCount > colCount) {
- break;
- }
+ Integer colspan = (Integer) column.getAttributes().get("colspan");
+ if (colspan != null && colspan.intValue() > 0) {
+ tColCount += colspan.intValue();
+ } else {
+ tColCount++;
+ }
- String classAttribute = facetName + "Class";
-
- String columnHeaderClass = (String) column.getAttributes().get(classAttribute);
-
- String styleClass = skinCellClass;
- if(headerClass != null && headerClass.trim().length() != 0) {
- styleClass = styleClass + " " + headerClass;
- }
-
- if(columnHeaderClass != null && columnHeaderClass.trim().length() != 0) {
- styleClass = styleClass + " " + columnHeaderClass;
- }
-
+ if (tColCount > colCount) {
+ break;
+ }
- writer.startElement(element, column);
-
- encodeStyleClass(writer, context, column, null, styleClass);
-
- writer.writeAttribute("scope", "col", null);
- getUtils().encodeAttribute(context, column, "colspan");
+ String classAttribute = facetName + "Class";
- UIComponent facet = column.getFacet(facetName);
- if (facet != null && facet.isRendered()) {
- renderChild(context, facet);
- }
+ String columnHeaderClass = (String)
column.getAttributes().get(classAttribute);
- writer.endElement(element);
- }
+ String styleClass = skinCellClass;
+ if (headerClass != null && headerClass.trim().length() != 0) {
+ styleClass = styleClass + " " + headerClass;
+ }
+
+ if (columnHeaderClass != null && columnHeaderClass.trim().length() !=
0) {
+ styleClass = styleClass + " " + columnHeaderClass;
+ }
+
+ writer.startElement(element, column);
+
+ encodeStyleClass(writer, context, column, null, styleClass);
+
+ writer.writeAttribute("scope", "col", null);
+ getUtils().encodeAttribute(context, column, "colspan");
+
+ UIComponent facet = column.getFacet(facetName);
+ if (facet != null && facet.isRendered()) {
+ renderChild(context, facet);
+ }
+
+ writer.endElement(element);
+ }
}
-
- protected void encodeStyleClass(ResponseWriter writer, FacesContext context,
UIComponent component , String styleClassAttribute, String styleClass) throws IOException
{
- boolean isEmpty = isEmptyAttr(component, styleClassAttribute);
- if( isEmpty && !(styleClass != null && styleClass.trim().length() !=
0)) {
- return;
- }
-
- String componentStyleClass = isEmpty ? styleClass : styleClass + " " +
component.getAttributes().get(styleClassAttribute);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, componentStyleClass, null);
- }
-
- protected boolean isEmptyAttr(UIComponent component, String attribute) {
- if(attribute == null) {
- return true;
- }
- String value = (String) component.getAttributes().get(attribute);
- return !(value != null && value.trim().length()!=0);
- }
-
- protected void encodeStyle(ResponseWriter writer, FacesContext context, UIComponent
component, String predefinedStyles) throws IOException {
- StringBuffer toEncode = new StringBuffer();
-
- if(!isEmptyAttr(component, HTML.STYLE_ATTRIBUTE)) {
- String style = ((String)component.getAttributes().get(HTML.STYLE_ATTRIBUTE)).trim();
- style = style.endsWith(";") ? style : style + ";";
- toEncode.append(style);
- }
-
- if(!isEmpty(predefinedStyles)) {
- String style = predefinedStyles.endsWith(";") ? predefinedStyles :
predefinedStyles + ";";
- toEncode.append(style);
- }
-
- if(toEncode.length() > 0) {
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, toEncode.toString(), null);
- }
- }
-
- protected boolean isEmpty(String style) {
- return !((style != null) && (style.trim().length()!=0));
- }
-
- protected String getTableSkinClass() {
- return "rich-table";
- }
-
- protected String getTableHeadSkinClass() {
- return "rich-table-head";
- }
-
- protected String getCaptionSkinClass() {
- return "rich-table-caption";
- }
+ protected void encodeStyleClass(ResponseWriter writer, FacesContext context,
UIComponent component,
+ String styleClassAttribute, String styleClass) throws IOException {
+ boolean isEmpty = isEmptyAttr(component, styleClassAttribute);
+ if (isEmpty && !(styleClass != null && styleClass.trim().length()
!= 0)) {
+ return;
+ }
+ String componentStyleClass = isEmpty ? styleClass : styleClass + " "
+ + component.getAttributes().get(styleClassAttribute);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, componentStyleClass, null);
+ }
+
+ protected boolean isEmptyAttr(UIComponent component, String attribute) {
+ if (attribute == null) {
+ return true;
+ }
+ String value = (String) component.getAttributes().get(attribute);
+ return !(value != null && value.trim().length() != 0);
+ }
+
+ protected void encodeStyle(ResponseWriter writer, FacesContext context, UIComponent
component,
+ String predefinedStyles) throws IOException {
+ StringBuffer toEncode = new StringBuffer();
+
+ if (!isEmptyAttr(component, HTML.STYLE_ATTRIBUTE)) {
+ String style = ((String)
component.getAttributes().get(HTML.STYLE_ATTRIBUTE)).trim();
+ style = style.endsWith(";") ? style : style + ";";
+ toEncode.append(style);
+ }
+
+ if (!isEmpty(predefinedStyles)) {
+ String style = predefinedStyles.endsWith(";") ? predefinedStyles :
predefinedStyles + ";";
+ toEncode.append(style);
+ }
+
+ if (toEncode.length() > 0) {
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, toEncode.toString(), null);
+ }
+ }
+
+ protected boolean isEmpty(String style) {
+ return !((style != null) && (style.trim().length() != 0));
+ }
+
+ protected String getTableSkinClass() {
+ return "rich-table";
+ }
+
+ protected String getTableHeadSkinClass() {
+ return "rich-table-head";
+ }
+
+ protected String getCaptionSkinClass() {
+ return "rich-table-caption";
+ }
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ElementEncodeListener.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -9,35 +9,47 @@
import org.richfaces.component.UIDataTableBase;
public interface ElementEncodeListener {
-
- public void encodeRowStart(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder) throws IOException;
-
- public void encodeRowEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException;
-
- public void encodeCellStart(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder) throws IOException;
-
- public void encodeCellEnd(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder) throws IOException;
-
-// public void encodeHeaderCellStart(ResponseWriter writer, FacesContext context,
UIComponent component, String styleClass) throws IOException;
-//
-// public void encodeHeaderCellEnd(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException;
-
- public void encodeFirstRowStart(ResponseWriter writer, FacesContext context,
UIComponent component, RowHolder holder) throws IOException;
-
- public void encodeFirstRowEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException;
-
- public void encodeTableStart(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable) throws IOException;
-
- public void encodeTableEnd(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException;
-
- public void encodeTableBodyStart(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable) throws IOException;
-
- public void encodeTableBodyEnd(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable) throws IOException;
-
-// public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException;
-
- public void encodeHeader(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException;
-
- public void encodeFooter(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException;
+ public void encodeRowStart(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder)
+ throws IOException;
+
+ public void encodeRowEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException;
+
+ public void encodeCellStart(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder)
+ throws IOException;
+
+ public void encodeCellEnd(ResponseWriter writer, FacesContext context, UIComponent
component, RowHolder holder)
+ throws IOException;
+
+ // public void encodeHeaderCellStart(ResponseWriter writer, FacesContext context,
UIComponent component, String
+ // styleClass) throws IOException;
+ //
+ // public void encodeHeaderCellEnd(ResponseWriter writer, FacesContext context,
UIComponent component) throws
+ // IOException;
+
+ public void encodeFirstRowStart(ResponseWriter writer, FacesContext context,
UIComponent component, RowHolder holder)
+ throws IOException;
+
+ public void encodeFirstRowEnd(ResponseWriter writer, FacesContext context,
UIComponent component)
+ throws IOException;
+
+ public void encodeTableStart(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable)
+ throws IOException;
+
+ public void encodeTableEnd(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable)
+ throws IOException;
+
+ public void encodeTableBodyStart(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable)
+ throws IOException;
+
+ public void encodeTableBodyEnd(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable)
+ throws IOException;
+
+ // public void encodeCaption(ResponseWriter writer, FacesContext context,
UIDataTableBase dataTable) throws
+ // IOException;
+
+ public void encodeHeader(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException;
+
+ public void encodeFooter(ResponseWriter writer, FacesContext context, UIDataTableBase
dataTable) throws IOException;
+
}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -18,7 +18,7 @@
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
+ */
package org.richfaces.renderkit;
import java.io.IOException;
@@ -36,286 +36,287 @@
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.util.HtmlUtil;
-@ResourceDependencies({
- @ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(name = "extendedDataTable.js"),
- @ResourceDependency(name = "extendedDataTable.css")
-})
+@ResourceDependencies( { @ResourceDependency(library = "javax.faces", name =
"jsf.js"),
+ @ResourceDependency(name = "jquery.js"), @ResourceDependency(name =
"richfaces.js"),
+ @ResourceDependency(name = "extendedDataTable.js"),
@ResourceDependency(name = "extendedDataTable.css") })
public class ExtendedDataTableRenderer extends AbstractTableRenderer {
-
- private class RendererState extends RowHolderBase{
-
- private UIDataTableBase table;
- private List<UIComponent> frozenColumns;
- private List<UIComponent> columns;
- private boolean frozen;
-
- public RendererState(FacesContext context, UIDataTableBase table) {
- super(context);
- this.table = table;
- int count = getFrozenColumnsCount();
- frozenColumns = new ArrayList<UIComponent>();
- columns = new ArrayList<UIComponent>();
- Iterator<UIComponent> iterator = table.columns();
- for (; iterator.hasNext() && count > 0; count--) {
- UIComponent component = iterator.next();
- if(component.isRendered()) {
- frozenColumns.add(component);
- }
- }
- for (; iterator.hasNext();) {
- UIComponent component = iterator.next();
- if(component.isRendered()) {
- columns.add(component);
- }
- }
- }
-
- private int getFrozenColumnsCount() {
- int count = ((Integer)
table.getAttributes().get("frozenColumns")).intValue();
- int columnsCount = getColumnsCount(table);
- if (count > columnsCount) {
- count = columnsCount;
- }
- return count;
- }
- public UIDataTableBase getRow() {
- return table;
- }
+ private class RendererState extends RowHolderBase {
- public List<UIComponent> getFrozenColumns() {
- return frozenColumns;
- }
+ private UIDataTableBase table;
+ private List<UIComponent> frozenColumns;
+ private List<UIComponent> columns;
+ private boolean frozen;
- public List<UIComponent> getColumns() {
- return columns;
- }
+ public RendererState(FacesContext context, UIDataTableBase table) {
+ super(context);
+ this.table = table;
+ int count = getFrozenColumnsCount();
+ frozenColumns = new ArrayList<UIComponent>();
+ columns = new ArrayList<UIComponent>();
+ Iterator<UIComponent> iterator = table.columns();
+ for (; iterator.hasNext() && count > 0; count--) {
+ UIComponent component = iterator.next();
+ if (component.isRendered()) {
+ frozenColumns.add(component);
+ }
+ }
+ for (; iterator.hasNext();) {
+ UIComponent component = iterator.next();
+ if (component.isRendered()) {
+ columns.add(component);
+ }
+ }
+ }
- public void setFrozen(boolean frozen) {
- this.frozen = frozen;
- }
+ private int getFrozenColumnsCount() {
+ int count = ((Integer)
table.getAttributes().get("frozenColumns")).intValue();
+ int columnsCount = getColumnsCount(table);
+ if (count > columnsCount) {
+ count = columnsCount;
+ }
+ return count;
+ }
- public boolean isFrozen() {
- return frozen;
- }
- }
+ public UIDataTableBase getRow() {
+ return table;
+ }
- @Override
- protected Class<? extends UIComponent> getComponentClass() {
- return UIDataTableBase.class;
- }
-
- @Override
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
- UIComponent component) throws IOException {
- writer.startElement(HTML.DIV_ELEM, component);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, component.getClientId(context), null);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
HtmlUtil.concatClasses("rich-extable",
(String)component.getAttributes().get("styleClass")), null);
- getUtils().writeAttribute(writer, HTML.STYLE_ATTRIBUTE,
component.getAttributes().get("style"));
-
- }
-
- @Override
- protected void doEncodeChildren(ResponseWriter writer,
- FacesContext context, UIComponent component) throws IOException {
- UIDataTableBase table = (UIDataTableBase) component;
- Object key = table.getRowKey();
- table.captureOrigValue(context);
- table.setRowKey(context, null);
- RendererState state = new RendererState(context, table);
- //TODO encodeCaption(context, table);
- encodeStyle(state);
- encodeHeaderOrFooter(state, "header");
- encodeBody(state);
- encodeHeaderOrFooter(state, "footer");
- table.setRowKey(context,key);
- table.restoreOrigValue(context);
- }
-
- @Override
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
- UIComponent component) throws IOException {
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- writer.write("new RichFaces.ExtendedDataTable('" +
component.getClientId(context) + "');");
- writer.endElement(HTML.SCRIPT_ELEM);
- writer.endElement(HTML.DIV_ELEM);
- }
-
- private void encodeStyle(RendererState state) throws IOException {
- FacesContext context = state.getContext();
- ResponseWriter writer = context.getResponseWriter();
- UIDataTableBase table = state.getRow();
- writer.startElement("style", table);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/css", null);
- writer.writeText(".rich-extable-part-width{", null); //TODO
getNormalizedId(context, state.getGrid())
- writer.writeText("width: 100%;", "width");
- writer.writeText("}", null);
- Iterator<UIComponent> columns = table.columns();
- while (columns.hasNext()) {
- UIComponent column = (UIComponent) columns.next();
- String id = column.getId();
- if (id == null) {
- column.getClientId(context); // hack initialize id
- id = column.getId();
- }
- String width = getColumnWidth(column);
- writer.writeText(".rich-extable-cell-width-" + id + " {",
"width"); //TODO getNormalizedId(context, state.getGrid())
- writer.writeText("width: " + width + ";", "width");
- writer.writeText("}", "width");
- }
- writer.endElement("style");
- }
-
- private void encodeHeaderOrFooter(RendererState state, String name) throws IOException
{
- FacesContext context = state.getContext();
- ResponseWriter writer = context.getResponseWriter();
- UIDataTableBase table = state.getRow();
- if (isColumnFacetPresent(table, name)) {
- writer.startElement(HTML.DIV_ELEM, table);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
HtmlUtil.concatClasses("rich-extable-" + name,
(String)table.getAttributes().get(name + "Class")), null);
- writer.startElement(HTML.TABLE_ELEMENT, table);
- writer.writeAttribute(HTML.CELLPADDING_ATTRIBUTE, "0", null);
- writer.writeAttribute(HTML.CELLSPACING_ATTRIBUTE, "0", null);
- writer.startElement(HTML.TBOBY_ELEMENT, table);
- writer.startElement(HTML.TR_ELEMENT, table);
- Iterator<UIComponent> columns = state.getFrozenColumns().iterator();
- for (int i = 0; i < 2; i++) { //TODO Replace 2 with constant
- if (columns.hasNext()) {
- writer.startElement(HTML.TD_ELEM, table);
- if (i == 0 && "footer".equals(name)) {
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-footer-align",
null);
- }
- writer.startElement(HTML.DIV_ELEM, table);
- if (i == 0) {
- if ("header".equals(name)) {
- writer.writeAttribute(HTML.ID_ATTRIBUTE, table.getClientId(context) +
":frozenHeader", null);
- }
- } else {
- writer.writeAttribute(HTML.ID_ATTRIBUTE, table.getClientId(context) + ":"
+ name, null);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable" +
("footer".equals(name) ? "-footer" : "") + "-part
rich-extable-part-width", null);
- }
- writer.startElement(HTML.TABLE_ELEMENT, table);
- writer.writeAttribute(HTML.CELLPADDING_ATTRIBUTE, "0", null);
- writer.writeAttribute(HTML.CELLSPACING_ATTRIBUTE, "0", null);
- writer.startElement(HTML.TBOBY_ELEMENT, table);
- writer.startElement(HTML.TR_ELEMENT, table);
- while (columns.hasNext()) {
- encodeHeaderOrFooterCell(context, writer, columns.next(), name);
- }
- writer.endElement(HTML.TR_ELEMENT);
- writer.endElement(HTML.TBOBY_ELEMENT);
- writer.endElement(HTML.TABLE_ELEMENT);
- writer.endElement(HTML.DIV_ELEM);
- writer.endElement(HTML.TD_ELEM);
- }
- columns = state.getColumns().iterator();
- }
- writer.endElement(HTML.TR_ELEMENT);
- writer.endElement(HTML.TBOBY_ELEMENT);
- writer.endElement(HTML.TABLE_ELEMENT);
- writer.endElement(HTML.DIV_ELEM);
- }
- }
+ public List<UIComponent> getFrozenColumns() {
+ return frozenColumns;
+ }
- private void encodeBody(RendererState state) throws IOException {
- FacesContext context = state.getContext();
- ResponseWriter writer = context.getResponseWriter();
- UIDataTableBase table = state.getRow();
- writer.startElement(HTML.DIV_ELEM, table);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, table.getClientId(context) + ":b",
null);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-body", null);
- writer.startElement(HTML.DIV_ELEM, table);
-// writer.startElement(HTML.DIV_ELEM, table); TODO
-// writer.write(" ");
-// writer.endElement(HTML.DIV_ELEM);
- writer.startElement(HTML.TABLE_ELEMENT, table);
- writer.writeAttribute(HTML.CELLPADDING_ATTRIBUTE, "0", null);
- writer.writeAttribute(HTML.CELLSPACING_ATTRIBUTE, "0", null);
- writer.startElement(HTML.TBOBY_ELEMENT, table);
- writer.startElement(HTML.TR_ELEMENT, table);
- state.setFrozen(true);
- for (int i = 0; i < 2; i++) { //TODO 1. Replace 2 with constant 2. Empty frozen part
shouldn't be rendered
- writer.startElement(HTML.TD_ELEM, table);
- writer.startElement(HTML.DIV_ELEM, table);
- if (i == 1) {
- writer.writeAttribute(HTML.ID_ATTRIBUTE, table.getClientId(context) +
":body", null);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-part
rich-extable-part-width", null);
- }
- writer.startElement(HTML.TABLE_ELEMENT, table);
- writer.writeAttribute(HTML.CELLPADDING_ATTRIBUTE, "0", null);
- writer.writeAttribute(HTML.CELLSPACING_ATTRIBUTE, "0", null);
- writer.startElement(HTML.TBOBY_ELEMENT, table);
- table.walk(context, this, state); //TODO encodeRows(context, table);
- writer.endElement(HTML.TBOBY_ELEMENT);
- writer.endElement(HTML.TABLE_ELEMENT);
- writer.endElement(HTML.DIV_ELEM);
- writer.endElement(HTML.TD_ELEM);
- state.setFrozen(false);
- }
- writer.endElement(HTML.TR_ELEMENT);
- writer.endElement(HTML.TBOBY_ELEMENT);
- writer.endElement(HTML.TABLE_ELEMENT);
- writer.endElement(HTML.DIV_ELEM);
- writer.endElement(HTML.DIV_ELEM);
- }
+ public List<UIComponent> getColumns() {
+ return columns;
+ }
- private void encodeHeaderOrFooterCell(FacesContext context, ResponseWriter writer,
- UIComponent column, String facetName) throws IOException {
- if (column.isRendered()) {
+ public void setFrozen(boolean frozen) {
+ this.frozen = frozen;
+ }
- String classAttribute = facetName + "Class";
- writer.startElement(HTML.TD_ELEM, column);
- writer.startElement(HTML.DIV_ELEM, column);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
HtmlUtil.concatClasses("rich-extable-" + facetName + "-cell",
"rich-extable-cell-width-" + column.getId(),
- (String) column.getAttributes().get(classAttribute)), null);
+ public boolean isFrozen() {
+ return frozen;
+ }
+ }
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIDataTableBase.class;
+ }
- UIComponent facet = column.getFacet(facetName);
- if (facet != null && facet.isRendered()) {
- renderChild(context, facet);
- }
+ @Override
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, component.getClientId(context), null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
HtmlUtil.concatClasses("rich-extable", (String) component
+ .getAttributes().get("styleClass")), null);
+ getUtils().writeAttribute(writer, HTML.STYLE_ATTRIBUTE,
component.getAttributes().get("style"));
- writer.endElement(HTML.DIV_ELEM);
- writer.endElement(HTML.TD_ELEM);
- }
- }
+ }
- @Override
- public void encodeRow(RowHolderBase rowHolder) throws IOException {
- FacesContext context = rowHolder.getContext();
- ResponseWriter writer = context.getResponseWriter();
- RendererState state = (RendererState)rowHolder;
- UIDataTableBase table = state.getRow();
- writer.startElement(HTML.TR_ELEMENT, table);
- Iterator<UIComponent> columns = null;
- if (state.isFrozen()) {
- columns = state.getFrozenColumns().iterator();
- } else {
- columns = state.getColumns().iterator();
- }
- while (columns.hasNext()) {
- UIComponent column = (UIComponent) columns.next();
- if (column.isRendered()) {
- writer.startElement(HTML.TD_ELEM, table);
- writer.startElement(HTML.DIV_ELEM, table);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-cell
rich-extable-cell-width-" + column.getId(), null);
- renderChildren(context, column);
- writer.endElement(HTML.DIV_ELEM);
- writer.endElement(HTML.TD_ELEM);
- }
- }
- writer.endElement(HTML.TR_ELEMENT);
- }
+ @Override
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context,
UIComponent component)
+ throws IOException {
+ UIDataTableBase table = (UIDataTableBase) component;
+ Object key = table.getRowKey();
+ table.captureOrigValue(context);
+ table.setRowKey(context, null);
+ RendererState state = new RendererState(context, table);
+ // TODO encodeCaption(context, table);
+ encodeStyle(state);
+ encodeHeaderOrFooter(state, "header");
+ encodeBody(state);
+ encodeHeaderOrFooter(state, "footer");
+ table.setRowKey(context, key);
+ table.restoreOrigValue(context);
+ }
- private String getColumnWidth(UIComponent column) {
- String width = (String) column.getAttributes().get("width");
- if (width == null || width.indexOf("%") != -1) {
- width = "100px";
- }
- return width;
- }
+ @Override
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ writer.write("new RichFaces.ExtendedDataTable('" +
component.getClientId(context) + "');");
+ writer.endElement(HTML.SCRIPT_ELEM);
+ writer.endElement(HTML.DIV_ELEM);
+ }
+
+ private void encodeStyle(RendererState state) throws IOException {
+ FacesContext context = state.getContext();
+ ResponseWriter writer = context.getResponseWriter();
+ UIDataTableBase table = state.getRow();
+ writer.startElement("style", table);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/css", null);
+ writer.writeText(".rich-extable-part-width{", null); // TODO
getNormalizedId(context, state.getGrid())
+ writer.writeText("width: 100%;", "width");
+ writer.writeText("}", null);
+ Iterator<UIComponent> columns = table.columns();
+ while (columns.hasNext()) {
+ UIComponent column = (UIComponent) columns.next();
+ String id = column.getId();
+ if (id == null) {
+ column.getClientId(context); // hack initialize id
+ id = column.getId();
+ }
+ String width = getColumnWidth(column);
+ writer.writeText(".rich-extable-cell-width-" + id + " {",
"width"); // TODO getNormalizedId(context,
+ //
state.getGrid())
+ writer.writeText("width: " + width + ";",
"width");
+ writer.writeText("}", "width");
+ }
+ writer.endElement("style");
+ }
+
+ private void encodeHeaderOrFooter(RendererState state, String name) throws
IOException {
+ FacesContext context = state.getContext();
+ ResponseWriter writer = context.getResponseWriter();
+ UIDataTableBase table = state.getRow();
+ if (isColumnFacetPresent(table, name)) {
+ writer.startElement(HTML.DIV_ELEM, table);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
HtmlUtil.concatClasses("rich-extable-" + name, (String) table
+ .getAttributes().get(name + "Class")), null);
+ writer.startElement(HTML.TABLE_ELEMENT, table);
+ writer.writeAttribute(HTML.CELLPADDING_ATTRIBUTE, "0", null);
+ writer.writeAttribute(HTML.CELLSPACING_ATTRIBUTE, "0", null);
+ writer.startElement(HTML.TBOBY_ELEMENT, table);
+ writer.startElement(HTML.TR_ELEMENT, table);
+ Iterator<UIComponent> columns = state.getFrozenColumns().iterator();
+ for (int i = 0; i < 2; i++) { // TODO Replace 2 with constant
+ if (columns.hasNext()) {
+ writer.startElement(HTML.TD_ELEM, table);
+ if (i == 0 && "footer".equals(name)) {
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
"rich-extable-footer-align", null);
+ }
+ writer.startElement(HTML.DIV_ELEM, table);
+ if (i == 0) {
+ if ("header".equals(name)) {
+ writer
+ .writeAttribute(HTML.ID_ATTRIBUTE,
table.getClientId(context) + ":frozenHeader", null);
+ }
+ } else {
+ writer.writeAttribute(HTML.ID_ATTRIBUTE,
table.getClientId(context) + ":" + name, null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE,
"rich-extable"
+ + ("footer".equals(name) ? "-footer" :
"") + "-part rich-extable-part-width", null);
+ }
+ writer.startElement(HTML.TABLE_ELEMENT, table);
+ writer.writeAttribute(HTML.CELLPADDING_ATTRIBUTE, "0",
null);
+ writer.writeAttribute(HTML.CELLSPACING_ATTRIBUTE, "0",
null);
+ writer.startElement(HTML.TBOBY_ELEMENT, table);
+ writer.startElement(HTML.TR_ELEMENT, table);
+ while (columns.hasNext()) {
+ encodeHeaderOrFooterCell(context, writer, columns.next(), name);
+ }
+ writer.endElement(HTML.TR_ELEMENT);
+ writer.endElement(HTML.TBOBY_ELEMENT);
+ writer.endElement(HTML.TABLE_ELEMENT);
+ writer.endElement(HTML.DIV_ELEM);
+ writer.endElement(HTML.TD_ELEM);
+ }
+ columns = state.getColumns().iterator();
+ }
+ writer.endElement(HTML.TR_ELEMENT);
+ writer.endElement(HTML.TBOBY_ELEMENT);
+ writer.endElement(HTML.TABLE_ELEMENT);
+ writer.endElement(HTML.DIV_ELEM);
+ }
+ }
+
+ private void encodeBody(RendererState state) throws IOException {
+ FacesContext context = state.getContext();
+ ResponseWriter writer = context.getResponseWriter();
+ UIDataTableBase table = state.getRow();
+ writer.startElement(HTML.DIV_ELEM, table);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, table.getClientId(context) +
":b", null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-body",
null);
+ writer.startElement(HTML.DIV_ELEM, table);
+ // writer.startElement(HTML.DIV_ELEM, table); TODO
+ // writer.write(" ");
+ // writer.endElement(HTML.DIV_ELEM);
+ writer.startElement(HTML.TABLE_ELEMENT, table);
+ writer.writeAttribute(HTML.CELLPADDING_ATTRIBUTE, "0", null);
+ writer.writeAttribute(HTML.CELLSPACING_ATTRIBUTE, "0", null);
+ writer.startElement(HTML.TBOBY_ELEMENT, table);
+ writer.startElement(HTML.TR_ELEMENT, table);
+ state.setFrozen(true);
+ for (int i = 0; i < 2; i++) { // TODO 1. Replace 2 with constant 2. Empty
frozen part shouldn't be rendered
+ writer.startElement(HTML.TD_ELEM, table);
+ writer.startElement(HTML.DIV_ELEM, table);
+ if (i == 1) {
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, table.getClientId(context) +
":body", null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-part
rich-extable-part-width", null);
+ }
+ writer.startElement(HTML.TABLE_ELEMENT, table);
+ writer.writeAttribute(HTML.CELLPADDING_ATTRIBUTE, "0", null);
+ writer.writeAttribute(HTML.CELLSPACING_ATTRIBUTE, "0", null);
+ writer.startElement(HTML.TBOBY_ELEMENT, table);
+ table.walk(context, this, state); // TODO encodeRows(context, table);
+ writer.endElement(HTML.TBOBY_ELEMENT);
+ writer.endElement(HTML.TABLE_ELEMENT);
+ writer.endElement(HTML.DIV_ELEM);
+ writer.endElement(HTML.TD_ELEM);
+ state.setFrozen(false);
+ }
+ writer.endElement(HTML.TR_ELEMENT);
+ writer.endElement(HTML.TBOBY_ELEMENT);
+ writer.endElement(HTML.TABLE_ELEMENT);
+ writer.endElement(HTML.DIV_ELEM);
+ writer.endElement(HTML.DIV_ELEM);
+ }
+
+ private void encodeHeaderOrFooterCell(FacesContext context, ResponseWriter writer,
UIComponent column,
+ String facetName) throws IOException {
+ if (column.isRendered()) {
+
+ String classAttribute = facetName + "Class";
+ writer.startElement(HTML.TD_ELEM, column);
+ writer.startElement(HTML.DIV_ELEM, column);
+ writer
+ .writeAttribute(HTML.CLASS_ATTRIBUTE,
HtmlUtil.concatClasses("rich-extable-" + facetName + "-cell",
+ "rich-extable-cell-width-" + column.getId(), (String)
column.getAttributes().get(classAttribute)),
+ null);
+
+ UIComponent facet = column.getFacet(facetName);
+ if (facet != null && facet.isRendered()) {
+ renderChild(context, facet);
+ }
+
+ writer.endElement(HTML.DIV_ELEM);
+ writer.endElement(HTML.TD_ELEM);
+ }
+ }
+
+ @Override
+ public void encodeRow(RowHolderBase rowHolder) throws IOException {
+ FacesContext context = rowHolder.getContext();
+ ResponseWriter writer = context.getResponseWriter();
+ RendererState state = (RendererState) rowHolder;
+ UIDataTableBase table = state.getRow();
+ writer.startElement(HTML.TR_ELEMENT, table);
+ Iterator<UIComponent> columns = null;
+ if (state.isFrozen()) {
+ columns = state.getFrozenColumns().iterator();
+ } else {
+ columns = state.getColumns().iterator();
+ }
+ while (columns.hasNext()) {
+ UIComponent column = (UIComponent) columns.next();
+ if (column.isRendered()) {
+ writer.startElement(HTML.TD_ELEM, table);
+ writer.startElement(HTML.DIV_ELEM, table);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-cell
rich-extable-cell-width-"
+ + column.getId(), null);
+ renderChildren(context, column);
+ writer.endElement(HTML.DIV_ELEM);
+ writer.endElement(HTML.TD_ELEM);
+ }
+ }
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ private String getColumnWidth(UIComponent column) {
+ String width = (String) column.getAttributes().get("width");
+ if (width == null || width.indexOf("%") != -1) {
+ width = "100px";
+ }
+ return width;
+ }
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolder.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -7,86 +7,83 @@
import org.richfaces.component.UIDataTable;
import org.richfaces.component.UISubTable;
-public class RowHolder extends RowHolderBase{
-
- private String cellElement;
-
- private String cellClass;
-
- private String rowClass;
-
- private String firstRowClass;
-
- private boolean headerRow;
-
-
- public boolean isHeaderRow() {
- return headerRow;
- }
+public class RowHolder extends RowHolderBase {
- public void setHeaderRow(boolean headerRow) {
- this.headerRow = headerRow;
- }
+ private String cellElement;
- private Row row;
-
- public RowHolder(FacesContext context, Row row) {
- super(context);
- this.row = row;
- }
-
- public String getCellClass() {
- return this.cellClass;
- }
-
- public void setCellClass(String cellClass) {
- this.cellClass = cellClass;
- }
+ private String cellClass;
- public String getRowClass() {
- return this.rowClass;
- }
-
- public void setRowClass(String rowClass) {
- this.rowClass = rowClass;
- }
-
- public String getFirstRowClass() {
- return this.firstRowClass;
- }
-
- public void setFirstRowClass(String firstRowClass) {
- this.firstRowClass = firstRowClass;
- }
+ private String rowClass;
- public String getCellElement() {
- return cellElement;
- }
+ private String firstRowClass;
- public void setCellElement(String cellElement) {
- this.cellElement = cellElement;
- }
-
- public Row getRow() {
- return this.row;
- }
+ private boolean headerRow;
+
+ private Row row;
- public void setRow(Row row) {
- this.row = row;
- }
-
- public boolean isColGroup(){
- return row instanceof UIColumnGroup;
- }
-
- public boolean isSubTable(){
- return row instanceof UISubTable;
- }
-
- public boolean isDataTable(){
- return row instanceof UIDataTable;
- }
-
+ public RowHolder(FacesContext context, Row row) {
+ super(context);
+ this.row = row;
+ }
-}
+ public boolean isHeaderRow() {
+ return headerRow;
+ }
+ public void setHeaderRow(boolean headerRow) {
+ this.headerRow = headerRow;
+ }
+
+ public String getCellClass() {
+ return this.cellClass;
+ }
+
+ public void setCellClass(String cellClass) {
+ this.cellClass = cellClass;
+ }
+
+ public String getRowClass() {
+ return this.rowClass;
+ }
+
+ public void setRowClass(String rowClass) {
+ this.rowClass = rowClass;
+ }
+
+ public String getFirstRowClass() {
+ return this.firstRowClass;
+ }
+
+ public void setFirstRowClass(String firstRowClass) {
+ this.firstRowClass = firstRowClass;
+ }
+
+ public String getCellElement() {
+ return cellElement;
+ }
+
+ public void setCellElement(String cellElement) {
+ this.cellElement = cellElement;
+ }
+
+ public Row getRow() {
+ return this.row;
+ }
+
+ public void setRow(Row row) {
+ this.row = row;
+ }
+
+ public boolean isColGroup() {
+ return row instanceof UIColumnGroup;
+ }
+
+ public boolean isSubTable() {
+ return row instanceof UISubTable;
+ }
+
+ public boolean isDataTable() {
+ return row instanceof UIDataTable;
+ }
+
+}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolderBase.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolderBase.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/RowHolderBase.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -5,35 +5,34 @@
import org.richfaces.component.Row;
public abstract class RowHolderBase {
-
- private FacesContext context;
- private int currentRow = 0;
+ private FacesContext context;
- public RowHolderBase(FacesContext context) {
- this.context = context;
- }
-
- public FacesContext getContext() {
- return context;
- }
+ private int currentRow = 0;
- public abstract Row getRow();
-
- public int getCurrentRow() {
- return currentRow;
- }
+ public RowHolderBase(FacesContext context) {
+ this.context = context;
+ }
- public int nextRow() {
- return ++currentRow;
- }
-
- public void setCurrentRow(int currentRow) {
- this.currentRow = currentRow;
- }
-
- public void resetCurrentRow() {
- this.currentRow = 0;
- }
-}
+ public FacesContext getContext() {
+ return context;
+ }
+ public abstract Row getRow();
+
+ public int getCurrentRow() {
+ return currentRow;
+ }
+
+ public int nextRow() {
+ return ++currentRow;
+ }
+
+ public void setCurrentRow(int currentRow) {
+ this.currentRow = currentRow;
+ }
+
+ public void resetCurrentRow() {
+ this.currentRow = 0;
+ }
+}
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 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -22,191 +22,191 @@
/**
* @author Anton Belevich
- *
+ *
*/
-@ResourceDependencies({
- @ResourceDependency(name = "toggler.js")
-})
+@ResourceDependencies( { @ResourceDependency(name = "toggler.js") })
public abstract class ToggleControlRendererBase extends RendererBase {
- private static final String MANAGER_SCRIPT = "<script
type=\"text/javascript\">ToggleManager.add(new Toggle(\"{0}\",
{1}));</script>";
-
- private static final String CLIENT_TOGGLE_SCRIPT =
"ToggleManager.clientToggle(''{0}'',
''{1}'');";
-
- private static final String SERVER_TOGGLE_SCRIPT =
"ToggleManager.serverToggle(''{0}'',
''{1}'');";
-
- private static final String AJAX_TOGGLE_SCRIPT =
"ToggleManager.ajaxToggle(''{0}'', ''{1}'');";
-
- private static final String DISPLAY_NONE = "display: none;";
-
- private static final String EXPAND_STATE = "expand";
-
- private static final String COLLAPSE_STATE = "collapse";
-
- private static final String HIDDEN = ":hidden";
-
- @Override
- protected void doDecode(FacesContext context, UIComponent component) {
- if(!(component instanceof UIToggleControl)) {
- return;
- }
-
- UIToggleControl toggle = (UIToggleControl)component;
-
- Map<String, String> params =
context.getExternalContext().getRequestParameterMap();
-
- String hiddenId = toggle.getClientId() + HIDDEN;
- String state = params.get(hiddenId);
-
- if(state != null && state.trim().length()> 0) {
-
- UIComponent processed = findComponent(context, toggle);
- if(processed instanceof Expandable) {
-
- String prevState = getState(((Expandable)processed).isExpanded());
- if(!state.equals(prevState)) {
- new ToggleEvent(processed, isExpanded(state)).queue();
- }
- }
- }
- }
-
- protected void encodeControl(FacesContext context, UIComponent component) throws
IOException{
-
- if(component instanceof UIToggleControl) {
- UIToggleControl toggleControl = (UIToggleControl)component;
-
- UISubTable subTable = findComponent(context, toggleControl);
- subTable.getAttributes().get("expanded");
- if(subTable != null) {
- ResponseWriter writer = context.getResponseWriter();
-
- String toggleId = toggleControl.getClientId(context);
- String options = encodeOptions(context, toggleControl, subTable);
-
- String registerScript = MessageFormat.format(MANAGER_SCRIPT, toggleId, options);
- writer.write(registerScript);
-
- String switchType = subTable.getSwichType();
- boolean expanded = subTable.isExpanded();
-
- encodeControl(context, writer, toggleControl, switchType, expanded, false);
- encodeControl(context, writer, toggleControl, switchType, !expanded, true);
-
- encodeHiddenInput(context, writer, toggleControl);
-
- }
- }
- }
-
- protected void encodeControl(FacesContext context, ResponseWriter writer,
UIToggleControl control, String switchType, boolean expanded, boolean visible) throws
IOException {
-
- String state = getState(expanded);
-
- String image = expanded ? control.getExpandControl() : control.getCollapseControl();
-
- String script = getScript(control, switchType, state);
-
- String style = getStyle(context, control);
- String styleClass = getStyleClass(context, control);
-
- writer.startElement(HTML.SPAN_ELEM, control);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, styleClass, null);
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, style, null);
-
- writer.startElement(HTML.IMG_ELEMENT,control);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, control.getClientId() + ":" + state,
null);
-
- if(!visible) {
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
- }
-
- if(script != null && script.length() > 0) {
- String eventName = control.getEvent();
- writer.writeAttribute(eventName,script, null);
- }
-
- if(image != null && image.trim().length() > 0) {
- writer.writeAttribute(HTML.SRC_ATTRIBUTE, image, null);
- }
-
- writer.endElement(HTML.IMG_ELEMENT);
- writer.endElement(HTML.SPAN_ELEM);
- }
-
- public String encodeOptions(FacesContext context, UIToggleControl toggleControl,
UISubTable subTable) {
-
- UIForm nestingForm = getUtils().getNestingForm(context, toggleControl);
-
- String formId = nestingForm.getClientId(context);
- String forId = subTable.getClientId(context);
- String state = getState(subTable.isExpanded());
-
- HashMap<String, String> options = new HashMap<String, String>();
- options.put("formId", formId);
- options.put("forId", forId);
- options.put("initialState", state);
-
- return ScriptUtils.toScript(options);
- }
-
- public void encodeHiddenInput(FacesContext context, ResponseWriter writer, UIComponent
component) throws IOException {
-
- String hiddenId = component.getClientId(context) +HIDDEN;
-
- writer.startElement(HTML.INPUT_ELEM, component);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, hiddenId, null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, hiddenId, null);
- writer.writeAttribute(HTML.TYPE_ATTR,"hidden", null);
- writer.endElement(HTML.INPUT_ELEM);
-
- }
-
- public String getStyleClass(FacesContext context, UIToggleControl control) {
- return null;
- }
-
- public String getStyle(FacesContext context, UIToggleControl control) {
- return null;
- }
-
- protected UISubTable findComponent(FacesContext context, UIToggleControl toggleControl)
{
- String forId = toggleControl.getForId();
-
- if(forId != null && forId.length() > 0) {
- UIComponent subTable = getUtils().findComponentFor(context, toggleControl, forId);
- if(subTable instanceof UISubTable) {
- return (UISubTable)subTable;
- }
- }
- return null;
- }
-
- public String getScript(UIToggleControl toggleControl, String switchType ,String state)
{
-
- StringBuffer pattern = new StringBuffer();
-
- if(switchType.equals(UISubTable.SWITCH_TYPE_CLIENT)) {
- pattern.append(CLIENT_TOGGLE_SCRIPT);
- } else if (switchType.equals(UISubTable.SWITCH_TYPE_AJAX)){
- pattern.append(AJAX_TOGGLE_SCRIPT);
- } else {
- pattern.append(SERVER_TOGGLE_SCRIPT);
- }
-
- String toggleId = toggleControl.getClientId();
-
- String script = ( pattern.length() > 0) ? MessageFormat.format(pattern.toString(),
toggleId, state) : null;
-
- return script;
- }
-
- protected String getState(boolean expand) {
- return expand ? EXPAND_STATE: COLLAPSE_STATE;
- }
-
- protected boolean isExpanded(String state) {
- return state.equals(EXPAND_STATE);
- }
-
+ private static final String MANAGER_SCRIPT = "<script
type=\"text/javascript\">ToggleManager.add(new Toggle(\"{0}\",
{1}));</script>";
+
+ private static final String CLIENT_TOGGLE_SCRIPT =
"ToggleManager.clientToggle(''{0}'',
''{1}'');";
+
+ private static final String SERVER_TOGGLE_SCRIPT =
"ToggleManager.serverToggle(''{0}'',
''{1}'');";
+
+ private static final String AJAX_TOGGLE_SCRIPT =
"ToggleManager.ajaxToggle(''{0}'', ''{1}'');";
+
+ private static final String DISPLAY_NONE = "display: none;";
+
+ private static final String EXPAND_STATE = "expand";
+
+ private static final String COLLAPSE_STATE = "collapse";
+
+ private static final String HIDDEN = ":hidden";
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ if (!(component instanceof UIToggleControl)) {
+ return;
+ }
+
+ UIToggleControl toggle = (UIToggleControl) component;
+
+ Map<String, String> params =
context.getExternalContext().getRequestParameterMap();
+
+ String hiddenId = toggle.getClientId() + HIDDEN;
+ String state = params.get(hiddenId);
+
+ if (state != null && state.trim().length() > 0) {
+
+ UIComponent processed = findComponent(context, toggle);
+ if (processed instanceof Expandable) {
+
+ String prevState = getState(((Expandable) processed).isExpanded());
+ if (!state.equals(prevState)) {
+ new ToggleEvent(processed, isExpanded(state)).queue();
+ }
+ }
+ }
+ }
+
+ protected void encodeControl(FacesContext context, UIComponent component) throws
IOException {
+
+ if (component instanceof UIToggleControl) {
+ UIToggleControl toggleControl = (UIToggleControl) component;
+
+ UISubTable subTable = findComponent(context, toggleControl);
+ subTable.getAttributes().get("expanded");
+ if (subTable != null) {
+ ResponseWriter writer = context.getResponseWriter();
+
+ String toggleId = toggleControl.getClientId(context);
+ String options = encodeOptions(context, toggleControl, subTable);
+
+ String registerScript = MessageFormat.format(MANAGER_SCRIPT, toggleId,
options);
+ writer.write(registerScript);
+
+ String switchType = subTable.getSwichType();
+ boolean expanded = subTable.isExpanded();
+
+ encodeControl(context, writer, toggleControl, switchType, expanded,
false);
+ encodeControl(context, writer, toggleControl, switchType, !expanded,
true);
+
+ encodeHiddenInput(context, writer, toggleControl);
+
+ }
+ }
+ }
+
+ protected void encodeControl(FacesContext context, ResponseWriter writer,
UIToggleControl control,
+ String switchType, boolean expanded, boolean visible) throws IOException {
+
+ String state = getState(expanded);
+
+ String image = expanded ? control.getExpandControl() :
control.getCollapseControl();
+
+ String script = getScript(control, switchType, state);
+
+ String style = getStyle(context, control);
+ String styleClass = getStyleClass(context, control);
+
+ writer.startElement(HTML.SPAN_ELEM, control);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, styleClass, null);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, style, null);
+
+ writer.startElement(HTML.IMG_ELEMENT, control);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, control.getClientId() + ":" +
state, null);
+
+ if (!visible) {
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
+ }
+
+ if (script != null && script.length() > 0) {
+ String eventName = control.getEvent();
+ writer.writeAttribute(eventName, script, null);
+ }
+
+ if (image != null && image.trim().length() > 0) {
+ writer.writeAttribute(HTML.SRC_ATTRIBUTE, image, null);
+ }
+
+ writer.endElement(HTML.IMG_ELEMENT);
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ public String encodeOptions(FacesContext context, UIToggleControl toggleControl,
UISubTable subTable) {
+
+ UIForm nestingForm = getUtils().getNestingForm(context, toggleControl);
+
+ String formId = nestingForm.getClientId(context);
+ String forId = subTable.getClientId(context);
+ String state = getState(subTable.isExpanded());
+
+ HashMap<String, String> options = new HashMap<String, String>();
+ options.put("formId", formId);
+ options.put("forId", forId);
+ options.put("initialState", state);
+
+ return ScriptUtils.toScript(options);
+ }
+
+ public void encodeHiddenInput(FacesContext context, ResponseWriter writer,
UIComponent component)
+ throws IOException {
+
+ String hiddenId = component.getClientId(context) + HIDDEN;
+
+ writer.startElement(HTML.INPUT_ELEM, component);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, hiddenId, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, hiddenId, null);
+ writer.writeAttribute(HTML.TYPE_ATTR, "hidden", null);
+ writer.endElement(HTML.INPUT_ELEM);
+
+ }
+
+ public String getStyleClass(FacesContext context, UIToggleControl control) {
+ return null;
+ }
+
+ public String getStyle(FacesContext context, UIToggleControl control) {
+ return null;
+ }
+
+ protected UISubTable findComponent(FacesContext context, UIToggleControl
toggleControl) {
+ String forId = toggleControl.getForId();
+
+ if (forId != null && forId.length() > 0) {
+ UIComponent subTable = getUtils().findComponentFor(context, toggleControl,
forId);
+ if (subTable instanceof UISubTable) {
+ return (UISubTable) subTable;
+ }
+ }
+ return null;
+ }
+
+ public String getScript(UIToggleControl toggleControl, String switchType, String
state) {
+
+ StringBuffer pattern = new StringBuffer();
+
+ if (switchType.equals(UISubTable.SWITCH_TYPE_CLIENT)) {
+ pattern.append(CLIENT_TOGGLE_SCRIPT);
+ } else if (switchType.equals(UISubTable.SWITCH_TYPE_AJAX)) {
+ pattern.append(AJAX_TOGGLE_SCRIPT);
+ } else {
+ pattern.append(SERVER_TOGGLE_SCRIPT);
+ }
+
+ String toggleId = toggleControl.getClientId();
+
+ String script = (pattern.length() > 0) ?
MessageFormat.format(pattern.toString(), toggleId, state) : null;
+
+ return script;
+ }
+
+ protected String getState(boolean expand) {
+ return expand ? EXPAND_STATE : COLLAPSE_STATE;
+ }
+
+ protected boolean isExpanded(String state) {
+ return state.equals(EXPAND_STATE);
+ }
+
}
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/taglib/SubTableHandler.java
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/taglib/SubTableHandler.java 2009-12-07
13:13:40 UTC (rev 16082)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/taglib/SubTableHandler.java 2009-12-07
13:22:33 UTC (rev 16083)
@@ -14,49 +14,49 @@
/**
* @author Anton Belevich
- *
+ *
*/
-public class SubTableHandler extends ComponentHandler{
+public class SubTableHandler extends ComponentHandler {
- private static final SubTableHandlerMetaRule metaRule = new SubTableHandlerMetaRule();
-
- public SubTableHandler(ComponentConfig config) {
- super(config);
- }
-
- @Override
- protected MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset m = super.createMetaRuleset(type);
- m.addRule(metaRule);
- return m;
- }
-
- static class SubTableHandlerMetaRule extends MetaRule {
+ private static final SubTableHandlerMetaRule METARULE = new
SubTableHandlerMetaRule();
- @Override
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if(meta.isTargetInstanceOf(UISubTable.class) &&
"toggleListener".equals(name)) {
- return new SubTableMapper(attribute);
- }
- return null;
- }
-
- }
-
- static class SubTableMapper extends Metadata {
+ public SubTableHandler(ComponentConfig config) {
+ super(config);
+ }
- private static final Class[] SIGNATURE = new Class[] {
org.richfaces.event.ToggleEvent.class };
-
- private final TagAttribute _attribute;
-
- public SubTableMapper(TagAttribute attribute) {
- this._attribute = attribute;
- }
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset m = super.createMetaRuleset(type);
+ m.addRule(METARULE);
+ return m;
+ }
- @Override
- public void applyMetadata(FaceletContext ctx, Object instance) {
- MethodExpression methodExpression = _attribute.getMethodExpression(ctx, null,
SIGNATURE);
- ((UISubTable)instance).setToggleListener(methodExpression);
- }
- }
+ static class SubTableHandlerMetaRule extends MetaRule {
+
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
+ if (meta.isTargetInstanceOf(UISubTable.class) &&
"toggleListener".equals(name)) {
+ return new SubTableMapper(attribute);
+ }
+ return null;
+ }
+
+ }
+
+ static class SubTableMapper extends Metadata {
+
+ private static final Class[] SIGNATURE = new Class[] {
org.richfaces.event.ToggleEvent.class };
+
+ private final TagAttribute attribute;
+
+ public SubTableMapper(TagAttribute attribute) {
+ this.attribute = attribute;
+ }
+
+ @Override
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ MethodExpression methodExpression = attribute.getMethodExpression(ctx, null,
SIGNATURE);
+ ((UISubTable) instance).setToggleListener(methodExpression);
+ }
+ }
}