You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sc...@apache.org on 2005/07/21 16:14:39 UTC
svn commit: r220086 - in /myfaces/tomahawk/trunk:
src/java/org/apache/myfaces/component/html/ext/
src/java/org/apache/myfaces/custom/crosstable/
src/java/org/apache/myfaces/renderkit/html/ext/
src/java/org/apache/myfaces/taglib/html/ext/ tld/
Author: schof
Date: Thu Jul 21 07:14:38 2005
New Revision: 220086
URL: http://svn.apache.org/viewcvs?rev=220086&view=rev
Log:
Fixes MYFACES-343 (support for onclick and ondblclick in x:dataTable)
Modified:
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/crosstable/HtmlColumnsTag.java
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java
myfaces/tomahawk/trunk/tld/myfaces_ext.tld
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java?rev=220086&r1=220085&r2=220086&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java Thu Jul 21 07:14:38 2005
@@ -39,23 +39,26 @@
*/
public class HtmlDataTable extends HtmlDataTableHack implements UserRoleAware
{
- private static final Log log = LogFactory.getLog(HtmlDataTable.class);
+ private static final Log log = LogFactory.getLog(HtmlDataTable.class);
- private static final int PROCESS_DECODES = 1;
- private static final int PROCESS_VALIDATORS = 2;
- private static final int PROCESS_UPDATES = 3;
+ private static final int PROCESS_DECODES = 1;
+ private static final int PROCESS_VALIDATORS = 2;
+ private static final int PROCESS_UPDATES = 3;
+
+ private static final boolean DEFAULT_SORTASCENDING = true;
+ private static final Class OBJECT_ARRAY_CLASS = (new Object[0]).getClass();
+
+ private _SerializableDataModel _preservedDataModel;
+
+ private String _sortColumn = null;
+ private Boolean _sortAscending = null;
+ private String _rowOnMouseOver = null;
+ private String _rowOnMouseOut = null;
+ private String _rowOnClick;
+ private String _rowOnDblClick;
+
- private static final boolean DEFAULT_SORTASCENDING = true;
- private static final Class OBJECT_ARRAY_CLASS = (new Object[0]).getClass();
-
- private _SerializableDataModel _preservedDataModel;
-
- private String _sortColumn = null;
- private Boolean _sortAscending = null;
- private String _rowOnMouseOver = null;
- private String _rowOnMouseOut = null;
-
- private boolean _isValidChilds = true;
+ private boolean _isValidChilds = true;
public void setRowIndex(int rowIndex)
{
@@ -71,506 +74,545 @@
{
Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
- if (previousRowDataVar != null && rowIndex >= 0) //we only need to provide the previousRowDataVar for a valid rowIndex
- {
- if (isRowAvailable())
- {
- //previous row is available
- requestMap.put(previousRowDataVar, getRowData());
- }
- else
- {
- //no previous row available
- requestMap.put(previousRowDataVar, null);
- }
- }
-
- super.setRowIndex(rowIndex);
-
- if (rowIndex >= 0)
- {
- //regular row index, update request scope variables
- if (rowIndexVar != null)
- {
- requestMap.put(rowIndexVar, new Integer(rowIndex));
- }
-
- if (rowCountVar != null)
- {
- requestMap.put(rowCountVar, new Integer(getRowCount()));
- }
- }
- else
- {
- //rowIndex == -1 means end of loop --> remove request scope variables
- if (rowIndexVar != null)
- {
- requestMap.remove(rowIndexVar);
- }
-
- if (rowCountVar != null)
- {
- requestMap.remove(rowCountVar);
- }
-
- if (previousRowDataVar != null)
- {
- requestMap.remove(previousRowDataVar);
- }
- }
- }
- else
- {
- // no extended var attributes defined, no special treatment
- super.setRowIndex(rowIndex);
- }
- }
-
- public void processDecodes(FacesContext context)
- {
- if (!isRendered())
- {
- return;
- }
- super.processDecodes(context);
- setRowIndex(-1);
- processColumns(context, PROCESS_DECODES);
- setRowIndex(-1);
- }
-
- /**
- * @param context
- * @param processAction
- */
- private void processColumns(FacesContext context, int processAction)
- {
- for (Iterator it = getChildren().iterator(); it.hasNext();)
- {
- UIComponent child = (UIComponent) it.next();
- if (child instanceof UIColumns)
- {
- process(context, child, processAction);
- }
- }
- }
-
- private void process(FacesContext context, UIComponent component, int processAction)
- {
- switch (processAction)
- {
- case PROCESS_DECODES:
- component.processDecodes(context);
- break;
- case PROCESS_VALIDATORS:
- component.processValidators(context);
- break;
- case PROCESS_UPDATES:
- component.processUpdates(context);
- break;
- }
- }
+ if (previousRowDataVar != null && rowIndex >= 0) //we only need to provide the previousRowDataVar for a valid rowIndex
+ {
+ if (isRowAvailable())
+ {
+ //previous row is available
+ requestMap.put(previousRowDataVar, getRowData());
+ }
+ else
+ {
+ //no previous row available
+ requestMap.put(previousRowDataVar, null);
+ }
+ }
+
+ super.setRowIndex(rowIndex);
+
+ if (rowIndex >= 0)
+ {
+ //regular row index, update request scope variables
+ if (rowIndexVar != null)
+ {
+ requestMap.put(rowIndexVar, new Integer(rowIndex));
+ }
+
+ if (rowCountVar != null)
+ {
+ requestMap.put(rowCountVar, new Integer(getRowCount()));
+ }
+ }
+ else
+ {
+ //rowIndex == -1 means end of loop --> remove request scope variables
+ if (rowIndexVar != null)
+ {
+ requestMap.remove(rowIndexVar);
+ }
+
+ if (rowCountVar != null)
+ {
+ requestMap.remove(rowCountVar);
+ }
+
+ if (previousRowDataVar != null)
+ {
+ requestMap.remove(previousRowDataVar);
+ }
+ }
+ }
+ else
+ {
+ // no extended var attributes defined, no special treatment
+ super.setRowIndex(rowIndex);
+ }
+ }
+
+ public void processDecodes(FacesContext context)
+ {
+ if (!isRendered())
+ {
+ return;
+ }
+ super.processDecodes(context);
+ setRowIndex(-1);
+ processColumns(context, PROCESS_DECODES);
+ setRowIndex(-1);
+ }
+
+ /**
+ * @param context
+ * @param processAction
+ */
+ private void processColumns(FacesContext context, int processAction)
+ {
+ for (Iterator it = getChildren().iterator(); it.hasNext();)
+ {
+ UIComponent child = (UIComponent) it.next();
+ if (child instanceof UIColumns)
+ {
+ process(context, child, processAction);
+ }
+ }
+ }
+
+ private void process(FacesContext context, UIComponent component, int processAction)
+ {
+ switch (processAction)
+ {
+ case PROCESS_DECODES:
+ component.processDecodes(context);
+ break;
+ case PROCESS_VALIDATORS:
+ component.processValidators(context);
+ break;
+ case PROCESS_UPDATES:
+ component.processUpdates(context);
+ break;
+ }
+ }
+
+ public void processValidators(FacesContext context)
+ {
+ if (!isRendered())
+ {
+ return;
+ }
+ super.processValidators(context);
+ processColumns(context, PROCESS_VALIDATORS);
+ setRowIndex(-1);
+
+ if (context.getRenderResponse())
+ {
+ _isValidChilds = false;
+ }
+ }
+
+ public void processUpdates(FacesContext context)
+ {
+ if (!isRendered())
+ {
+ return;
+ }
+ super.processUpdates(context);
+ processColumns(context, PROCESS_UPDATES);
+ setRowIndex(-1);
+
+ if (isPreserveDataModel())
+ {
+ updateModelFromPreservedDataModel(context);
+ }
+
+ if (context.getRenderResponse())
+ {
+ _isValidChilds = false;
+ }
+ }
+
+ private void updateModelFromPreservedDataModel(FacesContext context)
+ {
+ ValueBinding vb = getValueBinding("value");
+ if (vb != null && !vb.isReadOnly(context))
+ {
+ _SerializableDataModel dm = (_SerializableDataModel) getDataModel();
+ Class type = vb.getType(context);
+ if (DataModel.class.isAssignableFrom(type))
+ {
+ vb.setValue(context, dm);
+ }
+ else if (List.class.isAssignableFrom(type))
+ {
+ vb.setValue(context, dm.getWrappedData());
+ }
+ else if (OBJECT_ARRAY_CLASS.isAssignableFrom(type))
+ {
+ List lst = (List) dm.getWrappedData();
+ vb.setValue(context, lst.toArray(new Object[lst.size()]));
+ }
+ else if (ResultSet.class.isAssignableFrom(type))
+ {
+ throw new UnsupportedOperationException(this.getClass().getName()
+ + " UnsupportedOperationException");
+ }
+ else
+ {
+ //Assume scalar data model
+ List lst = (List) dm.getWrappedData();
+ if (lst.size() > 0)
+ {
+ vb.setValue(context, lst.get(0));
+ }
+ else
+ {
+ vb.setValue(context, null);
+ }
+ }
+ }
+ _preservedDataModel = null;
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ if (!isRendered())
+ return;
+
+ if (_isValidChilds)
+ {
+ _preservedDataModel = null;
+ }
+
+ if (isRenderedIfEmpty() || getRowCount() > 0)
+ {
+ super.encodeBegin(context);
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();)
+ {
+ UIComponent component = (UIComponent) iter.next();
+ if (component instanceof UIColumns)
+ {
+ ((UIColumns) component).encodeTableBegin(context);
+ }
+ }
+ }
+ }
+
+ /**
+ * @see javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
+ */
+ public void encodeChildren(FacesContext context) throws IOException
+ {
+ if (isRenderedIfEmpty() || getRowCount() > 0)
+ {
+ super.encodeChildren(context);
+ }
+ }
+
+ /**
+ * @see javax.faces.component.UIData#encodeEnd(javax.faces.context.FacesContext)
+ */
+ public void encodeEnd(FacesContext context) throws IOException
+ {
+ if (isRenderedIfEmpty() || getRowCount() > 0)
+ {
+ super.encodeEnd(context);
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();)
+ {
+ UIComponent component = (UIComponent) iter.next();
+ if (component instanceof UIColumns)
+ {
+ ((UIColumns) component).encodeTableEnd(context);
+ }
+ }
+ }
+ }
+
+ public int getFirst()
+ {
+ if (_preservedDataModel != null)
+ {
+ //Rather get the currently restored DataModel attribute
+ return ((_SerializableDataModel) _preservedDataModel).getFirst();
+ }
+ else
+ {
+ return super.getFirst();
+ }
+ }
+
+ public void setFirst(int first)
+ {
+ if (_preservedDataModel != null)
+ {
+ //Also change the currently restored DataModel attribute
+ ((_SerializableDataModel) _preservedDataModel).setFirst(first);
+ }
+ super.setFirst(first);
+ }
+
+ public int getRows()
+ {
+ if (_preservedDataModel != null)
+ {
+ //Rather get the currently restored DataModel attribute
+ return ((_SerializableDataModel) _preservedDataModel).getRows();
+ }
+ else
+ {
+ return super.getRows();
+ }
+ }
+
+ public void setRows(int rows)
+ {
+ if (_preservedDataModel != null)
+ {
+ //Also change the currently restored DataModel attribute
+ ((_SerializableDataModel) _preservedDataModel).setRows(rows);
+ }
+ super.setRows(rows);
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ boolean preserveSort = isPreserveSort();
+ Object values[] = new Object[13];
+ values[0] = super.saveState(context);
+ values[1] = _preserveDataModel;
+ if (isPreserveDataModel())
+ {
+ values[2] = saveAttachedState(context, getSerializableDataModel());
+ }
+ else
+ {
+ values[2] = null;
+ }
+ values[3] = _preserveSort;
+ values[4] = _sortColumn;
+ values[5] = _sortAscending;
+ values[6] = _renderedIfEmpty;
+ values[7] = _rowCountVar;
+ values[8] = _rowIndexVar;
+ values[9] = _rowOnMouseOver;
+ values[10] = _rowOnMouseOut;
+
+ values[11] = preserveSort ? getSortColumn() : null;
+ values[12] = preserveSort ? Boolean.valueOf(isSortAscending()) : null;
+ return values;
+ }
+
+ /**
+ * @see org.apache.myfaces.component.html.ext.HtmlDataTableHack#getDataModel()
+ */
+ protected DataModel getDataModel()
+ {
+ if (_preservedDataModel != null)
+ {
+ setDataModel(_preservedDataModel);
+ _preservedDataModel = null;
+ }
+ return super.getDataModel();
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+ _preserveDataModel = (Boolean) values[1];
+ if (isPreserveDataModel())
+ {
+ _preservedDataModel = (_SerializableDataModel) restoreAttachedState(context, values[2]);
+ }
+ else
+ {
+ _preservedDataModel = null;
+ }
+ _preserveSort = (Boolean) values[3];
+ _sortColumn = (String) values[4];
+ _sortAscending = (Boolean) values[5];
+ _renderedIfEmpty = (Boolean) values[6];
+ _rowCountVar = (String) values[7];
+ _rowIndexVar = (String) values[8];
+ _rowOnMouseOver = (String) values[9];
+ _rowOnMouseOut = (String) values[10];
+
+ if (isPreserveSort())
+ {
+ String sortColumn = (String) values[11];
+ Boolean sortAscending = (Boolean) values[12];
+ if (sortColumn != null && sortAscending != null)
+ {
+ ValueBinding vb = getValueBinding("sortColumn");
+ if (vb != null && !vb.isReadOnly(context))
+ {
+ vb.setValue(context, sortColumn);
+ }
+
+ vb = getValueBinding("sortAscending");
+ if (vb != null && !vb.isReadOnly(context))
+ {
+ vb.setValue(context, sortAscending);
+ }
+ }
+ }
+ }
+
+ public _SerializableDataModel getSerializableDataModel()
+ {
+ DataModel dm = getDataModel();
+ if (dm instanceof _SerializableDataModel)
+ {
+ return (_SerializableDataModel) dm;
+ }
+ return createSerializableDataModel();
+ }
+
+ /**
+ * @return
+ */
+ private _SerializableDataModel createSerializableDataModel()
+ {
+ Object value = getValue();
+ if (value == null)
+ {
+ return null;
+ }
+ else if (value instanceof DataModel)
+ {
+ return new _SerializableDataModel(getFirst(), getRows(), (DataModel) value);
+ }
+ else if (value instanceof List)
+ {
+ return new _SerializableListDataModel(getFirst(), getRows(), (List) value);
+ }
+ else if (OBJECT_ARRAY_CLASS.isAssignableFrom(value.getClass()))
+ {
+ return new _SerializableArrayDataModel(getFirst(), getRows(), (Object[]) value);
+ }
+ else if (value instanceof ResultSet)
+ {
+ return new _SerializableResultSetDataModel(getFirst(), getRows(), (ResultSet) value);
+ }
+ else if (value instanceof javax.servlet.jsp.jstl.sql.Result)
+ {
+ return new _SerializableResultDataModel(getFirst(), getRows(),
+ (javax.servlet.jsp.jstl.sql.Result) value);
+ }
+ else
+ {
+ return new _SerializableScalarDataModel(getFirst(), getRows(), value);
+ }
+ }
+
+ public boolean isRendered()
+ {
+ if (!UserRoleUtils.isVisibleOnUserRole(this))
+ return false;
+ return super.isRendered();
+ }
+
+ public void setSortColumn(String sortColumn)
+ {
+ _sortColumn = sortColumn;
+ // update model is necessary here, because processUpdates is never called
+ // reason: HtmlCommandSortHeader.isImmediate() == true
+ ValueBinding vb = getValueBinding("sortColumn");
+ if (vb != null)
+ {
+ vb.setValue(getFacesContext(), _sortColumn);
+ _sortColumn = null;
+ }
+ }
+
+ public String getSortColumn()
+ {
+ if (_sortColumn != null)
+ return _sortColumn;
+ ValueBinding vb = getValueBinding("sortColumn");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setSortAscending(boolean sortAscending)
+ {
+ _sortAscending = Boolean.valueOf(sortAscending);
+ // update model is necessary here, because processUpdates is never called
+ // reason: HtmlCommandSortHeader.isImmediate() == true
+ ValueBinding vb = getValueBinding("sortAscending");
+ if (vb != null)
+ {
+ vb.setValue(getFacesContext(), _sortAscending);
+ _sortAscending = null;
+ }
+ }
+
+ public boolean isSortAscending()
+ {
+ if (_sortAscending != null)
+ return _sortAscending.booleanValue();
+ ValueBinding vb = getValueBinding("sortAscending");
+ Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
+ return v != null ? v.booleanValue() : DEFAULT_SORTASCENDING;
+ }
+
+ public void setRowOnMouseOver(String rowOnMouseOver)
+ {
+ _rowOnMouseOver = rowOnMouseOver;
+ // update model is necessary here, because processUpdates is never called
+ // reason: HtmlCommandSortHeader.isImmediate() == true
+ ValueBinding vb = getValueBinding("rowOnMouseOver");
+ if (vb != null)
+ {
+ vb.setValue(getFacesContext(), _rowOnMouseOver);
+ _rowOnMouseOver = null;
+ }
+ }
+
+ public String getRowOnMouseOver()
+ {
+ if (_rowOnMouseOver != null)
+ return _rowOnMouseOver;
+ ValueBinding vb = getValueBinding("rowOnMouseOver");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setRowOnMouseOut(String rowOnMouseOut)
+ {
+ _rowOnMouseOut = rowOnMouseOut;
+ // update model is necessary here, because processUpdates is never called
+ // reason: HtmlCommandSortHeader.isImmediate() == true
+ ValueBinding vb = getValueBinding("rowOnMouseOut");
+ if (vb != null)
+ {
+ vb.setValue(getFacesContext(), _rowOnMouseOut);
+ _rowOnMouseOut = null;
+ }
+ }
+
+ public String getRowOnMouseOut()
+ {
+ if (_rowOnMouseOut != null)
+ return _rowOnMouseOut;
+ ValueBinding vb = getValueBinding("rowOnMouseOut");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setRowOnClick(String rowOnClick)
+ {
+ _rowOnClick = rowOnClick;
+ ValueBinding vb = getValueBinding("rowOnClick");
+ if (vb != null)
+ {
+ vb.setValue(getFacesContext(), _rowOnClick);
+ _rowOnClick = null;
+ }
+ }
+
+ public String getRowOnClick()
+ {
+ if (_rowOnClick != null)
+ return _rowOnClick;
+ ValueBinding vb = getValueBinding("rowOnClick");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setRowOnDblClick(String rowOnDblClick)
+ {
+ _rowOnDblClick = rowOnDblClick;
+ ValueBinding vb = getValueBinding("rowOnDblClick");
+ if (vb != null)
+ {
+ vb.setValue(getFacesContext(), _rowOnDblClick);
+ _rowOnDblClick = null;
+ }
+ }
+
+ public String getRowOnDblClick()
+ {
+ if (_rowOnDblClick != null)
+ return _rowOnDblClick;
+ ValueBinding vb = getValueBinding("rowOnDblClick");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
- public void processValidators(FacesContext context)
- {
- if (!isRendered())
- {
- return;
- }
- super.processValidators(context);
- processColumns(context, PROCESS_VALIDATORS);
- setRowIndex(-1);
-
- if (context.getRenderResponse())
- {
- _isValidChilds = false;
- }
- }
-
- public void processUpdates(FacesContext context)
- {
- if (!isRendered())
- {
- return;
- }
- super.processUpdates(context);
- processColumns(context, PROCESS_UPDATES);
- setRowIndex(-1);
-
- if (isPreserveDataModel())
- {
- updateModelFromPreservedDataModel(context);
- }
-
- if (context.getRenderResponse())
- {
- _isValidChilds = false;
- }
- }
-
- private void updateModelFromPreservedDataModel(FacesContext context)
- {
- ValueBinding vb = getValueBinding("value");
- if (vb != null && !vb.isReadOnly(context))
- {
- _SerializableDataModel dm = (_SerializableDataModel) getDataModel();
- Class type = vb.getType(context);
- if (DataModel.class.isAssignableFrom(type))
- {
- vb.setValue(context, dm);
- }
- else if (List.class.isAssignableFrom(type))
- {
- vb.setValue(context, dm.getWrappedData());
- }
- else if (OBJECT_ARRAY_CLASS.isAssignableFrom(type))
- {
- List lst = (List) dm.getWrappedData();
- vb.setValue(context, lst.toArray(new Object[lst.size()]));
- }
- else if (ResultSet.class.isAssignableFrom(type))
- {
- throw new UnsupportedOperationException(this.getClass().getName()
- + " UnsupportedOperationException");
- }
- else
- {
- //Assume scalar data model
- List lst = (List) dm.getWrappedData();
- if (lst.size() > 0)
- {
- vb.setValue(context, lst.get(0));
- }
- else
- {
- vb.setValue(context, null);
- }
- }
- }
- _preservedDataModel = null;
- }
-
- public void encodeBegin(FacesContext context) throws IOException
- {
- if (!isRendered())
- return;
-
- if (_isValidChilds)
- {
- _preservedDataModel = null;
- }
-
- if (isRenderedIfEmpty() || getRowCount() > 0)
- {
- super.encodeBegin(context);
- for (Iterator iter = getChildren().iterator(); iter.hasNext();)
- {
- UIComponent component = (UIComponent) iter.next();
- if (component instanceof UIColumns)
- {
- ((UIColumns) component).encodeTableBegin(context);
- }
- }
- }
- }
-
- /**
- * @see javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
- */
- public void encodeChildren(FacesContext context) throws IOException
- {
- if (isRenderedIfEmpty() || getRowCount() > 0)
- {
- super.encodeChildren(context);
- }
- }
-
- /**
- * @see javax.faces.component.UIData#encodeEnd(javax.faces.context.FacesContext)
- */
- public void encodeEnd(FacesContext context) throws IOException
- {
- if (isRenderedIfEmpty() || getRowCount() > 0)
- {
- super.encodeEnd(context);
- for (Iterator iter = getChildren().iterator(); iter.hasNext();)
- {
- UIComponent component = (UIComponent) iter.next();
- if (component instanceof UIColumns)
- {
- ((UIColumns) component).encodeTableEnd(context);
- }
- }
- }
- }
-
- public int getFirst()
- {
- if (_preservedDataModel != null)
- {
- //Rather get the currently restored DataModel attribute
- return ((_SerializableDataModel) _preservedDataModel).getFirst();
- }
- else
- {
- return super.getFirst();
- }
- }
-
- public void setFirst(int first)
- {
- if (_preservedDataModel != null)
- {
- //Also change the currently restored DataModel attribute
- ((_SerializableDataModel) _preservedDataModel).setFirst(first);
- }
- super.setFirst(first);
- }
-
- public int getRows()
- {
- if (_preservedDataModel != null)
- {
- //Rather get the currently restored DataModel attribute
- return ((_SerializableDataModel) _preservedDataModel).getRows();
- }
- else
- {
- return super.getRows();
- }
- }
-
- public void setRows(int rows)
- {
- if (_preservedDataModel != null)
- {
- //Also change the currently restored DataModel attribute
- ((_SerializableDataModel) _preservedDataModel).setRows(rows);
- }
- super.setRows(rows);
- }
-
- public Object saveState(FacesContext context)
- {
- boolean preserveSort = isPreserveSort();
- Object values[] = new Object[13];
- values[0] = super.saveState(context);
- values[1] = _preserveDataModel;
- if (isPreserveDataModel())
- {
- values[2] = saveAttachedState(context, getSerializableDataModel());
- }
- else
- {
- values[2] = null;
- }
- values[3] = _preserveSort;
- values[4] = _sortColumn;
- values[5] = _sortAscending;
- values[6] = _renderedIfEmpty;
- values[7] = _rowCountVar;
- values[8] = _rowIndexVar;
- values[9] = _rowOnMouseOver;
- values[10] = _rowOnMouseOut;
-
- values[11] = preserveSort ? getSortColumn() : null;
- values[12] = preserveSort ? Boolean.valueOf(isSortAscending()) : null;
- return values;
- }
-
- /**
- * @see org.apache.myfaces.component.html.ext.HtmlDataTableHack#getDataModel()
- */
- protected DataModel getDataModel()
- {
- if (_preservedDataModel != null)
- {
- setDataModel(_preservedDataModel);
- _preservedDataModel = null;
- }
- return super.getDataModel();
- }
-
- public void restoreState(FacesContext context, Object state)
- {
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
- _preserveDataModel = (Boolean) values[1];
- if (isPreserveDataModel())
- {
- _preservedDataModel = (_SerializableDataModel) restoreAttachedState(context, values[2]);
- }
- else
- {
- _preservedDataModel = null;
- }
- _preserveSort = (Boolean) values[3];
- _sortColumn = (String) values[4];
- _sortAscending = (Boolean) values[5];
- _renderedIfEmpty = (Boolean) values[6];
- _rowCountVar = (String) values[7];
- _rowIndexVar = (String) values[8];
- _rowOnMouseOver = (String) values[9];
- _rowOnMouseOut = (String) values[10];
-
- if (isPreserveSort())
- {
- String sortColumn = (String) values[11];
- Boolean sortAscending = (Boolean) values[12];
- if (sortColumn != null && sortAscending != null)
- {
- ValueBinding vb = getValueBinding("sortColumn");
- if (vb != null && !vb.isReadOnly(context))
- {
- vb.setValue(context, sortColumn);
- }
-
- vb = getValueBinding("sortAscending");
- if (vb != null && !vb.isReadOnly(context))
- {
- vb.setValue(context, sortAscending);
- }
- }
- }
- }
-
- public _SerializableDataModel getSerializableDataModel()
- {
- DataModel dm = getDataModel();
- if (dm instanceof _SerializableDataModel)
- {
- return (_SerializableDataModel) dm;
- }
- return createSerializableDataModel();
- }
-
- /**
- * @return
- */
- private _SerializableDataModel createSerializableDataModel()
- {
- Object value = getValue();
- if (value == null)
- {
- return null;
- }
- else if (value instanceof DataModel)
- {
- return new _SerializableDataModel(getFirst(), getRows(), (DataModel) value);
- }
- else if (value instanceof List)
- {
- return new _SerializableListDataModel(getFirst(), getRows(), (List) value);
- }
- else if (OBJECT_ARRAY_CLASS.isAssignableFrom(value.getClass()))
- {
- return new _SerializableArrayDataModel(getFirst(), getRows(), (Object[]) value);
- }
- else if (value instanceof ResultSet)
- {
- return new _SerializableResultSetDataModel(getFirst(), getRows(), (ResultSet) value);
- }
- else if (value instanceof javax.servlet.jsp.jstl.sql.Result)
- {
- return new _SerializableResultDataModel(getFirst(), getRows(),
- (javax.servlet.jsp.jstl.sql.Result) value);
- }
- else
- {
- return new _SerializableScalarDataModel(getFirst(), getRows(), value);
- }
- }
-
- public boolean isRendered()
- {
- if (!UserRoleUtils.isVisibleOnUserRole(this))
- return false;
- return super.isRendered();
- }
-
- public void setSortColumn(String sortColumn)
- {
- _sortColumn = sortColumn;
- // update model is necessary here, because processUpdates is never called
- // reason: HtmlCommandSortHeader.isImmediate() == true
- ValueBinding vb = getValueBinding("sortColumn");
- if (vb != null)
- {
- vb.setValue(getFacesContext(), _sortColumn);
- _sortColumn = null;
- }
- }
-
- public String getSortColumn()
- {
- if (_sortColumn != null)
- return _sortColumn;
- ValueBinding vb = getValueBinding("sortColumn");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setSortAscending(boolean sortAscending)
- {
- _sortAscending = Boolean.valueOf(sortAscending);
- // update model is necessary here, because processUpdates is never called
- // reason: HtmlCommandSortHeader.isImmediate() == true
- ValueBinding vb = getValueBinding("sortAscending");
- if (vb != null)
- {
- vb.setValue(getFacesContext(), _sortAscending);
- _sortAscending = null;
- }
- }
-
- public boolean isSortAscending()
- {
- if (_sortAscending != null)
- return _sortAscending.booleanValue();
- ValueBinding vb = getValueBinding("sortAscending");
- Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
- return v != null ? v.booleanValue() : DEFAULT_SORTASCENDING;
- }
-
- public void setRowOnMouseOver(String rowOnMouseOver)
- {
- _rowOnMouseOver = rowOnMouseOver;
- // update model is necessary here, because processUpdates is never called
- // reason: HtmlCommandSortHeader.isImmediate() == true
- ValueBinding vb = getValueBinding("rowOnMouseOver");
- if (vb != null)
- {
- vb.setValue(getFacesContext(), _rowOnMouseOver);
- _rowOnMouseOver = null;
- }
- }
-
- public String getRowOnMouseOver()
- {
- if (_rowOnMouseOver != null)
- return _rowOnMouseOver;
- ValueBinding vb = getValueBinding("rowOnMouseOver");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setRowOnMouseOut(String rowOnMouseOut)
- {
- _rowOnMouseOut = rowOnMouseOut;
- // update model is necessary here, because processUpdates is never called
- // reason: HtmlCommandSortHeader.isImmediate() == true
- ValueBinding vb = getValueBinding("rowOnMouseOut");
- if (vb != null)
- {
- vb.setValue(getFacesContext(), _rowOnMouseOut);
- _rowOnMouseOut = null;
- }
- }
-
- public String getRowOnMouseOut()
- {
- if (_rowOnMouseOut != null)
- return _rowOnMouseOut;
- ValueBinding vb = getValueBinding("rowOnMouseOut");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
//------------------ GENERATED CODE BEGIN (do not modify!) --------------------
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/crosstable/HtmlColumnsTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/crosstable/HtmlColumnsTag.java?rev=220086&r1=220085&r2=220086&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/crosstable/HtmlColumnsTag.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/crosstable/HtmlColumnsTag.java Thu Jul 21 07:14:38 2005
@@ -27,6 +27,7 @@
public class HtmlColumnsTag extends HtmlComponentBodyTagBase
{
private String mVar;
+ private String _width;
/**
* @see javax.faces.webapp.UIComponentTag#getComponentType()
@@ -48,11 +49,17 @@
{
mVar = var;
}
+
+ public void setWidth(String width)
+ {
+ _width = width;
+ }
protected void setProperties(UIComponent component)
{
super.setProperties(component);
setStringProperty(component, JSFAttr.VAR_ATTR, mVar);
+ setStringProperty(component, "width", _width);
}
}
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java?rev=220086&r1=220085&r2=220086&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java Thu Jul 21 07:14:38 2005
@@ -32,6 +32,8 @@
HtmlDataTable table = (HtmlDataTable) uiData;
String rowOnMouseOver = table.getRowOnMouseOver();
String rowOnMouseOut = table.getRowOnMouseOut();
+ String rowOnClick = table.getRowOnClick();
+ String rowOnDblClick = table.getRowOnDblClick();
// render onmouseover and onmouseout handlers if not null
if (rowOnMouseOver != null)
@@ -41,6 +43,14 @@
if (rowOnMouseOut != null)
{
writer.writeAttribute(HTML.ONMOUSEOUT_ATTR, rowOnMouseOut, null);
+ }
+ if (rowOnClick != null)
+ {
+ writer.writeAttribute(HTML.ONCLICK_ATTR, rowOnClick, null);
+ }
+ if (rowOnDblClick != null)
+ {
+ writer.writeAttribute(HTML.ONDBLCLICK_ATTR, rowOnDblClick, null);
}
}
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java?rev=220086&r1=220085&r2=220086&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java Thu Jul 21 07:14:38 2005
@@ -52,6 +52,8 @@
private String _previousRowDataVar;
private String _rowOnMouseOver;
private String _rowOnMouseOut;
+ private String _rowOnClick;
+ private String _rowOnDblClick;
public void release() {
super.release();
@@ -68,6 +70,8 @@
_previousRowDataVar=null;
_rowOnMouseOver=null;
_rowOnMouseOut=null;
+ _rowOnClick = null;
+ _rowOnDblClick = null;
}
@@ -87,6 +91,8 @@
setStringProperty(component, "previousRowDataVar", _previousRowDataVar);
setStringProperty(component, "rowOnMouseOver", _rowOnMouseOver);
setStringProperty(component, "rowOnMouseOut", _rowOnMouseOut);
+ setStringProperty(component, "rowOnClick", _rowOnClick);
+ setStringProperty(component, "rowOnDblClick", _rowOnDblClick);
}
public void setPreserveDataModel(String preserveDataModel)
@@ -148,4 +154,15 @@
{
_rowOnMouseOut = rowOnMouseOut;
}
+
+ public void setRowOnClick(String rowOnClick)
+ {
+ _rowOnClick = rowOnClick;
+ }
+
+ public void setRowOnDblClick(String rowOnDblClick)
+ {
+ _rowOnDblClick = rowOnDblClick;
+ }
+
}
Modified: myfaces/tomahawk/trunk/tld/myfaces_ext.tld
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/tld/myfaces_ext.tld?rev=220086&r1=220085&r2=220086&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/tld/myfaces_ext.tld (original)
+++ myfaces/tomahawk/trunk/tld/myfaces_ext.tld Thu Jul 21 07:14:38 2005
@@ -223,6 +223,18 @@
Defines a JavaScript onmouseout event handler for each table row
</description>
</attribute>
+ <attribute>
+ <name>rowOnClick</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>Defines a JavaScript onclick event handler for each table row</description>
+ </attribute>
+ <attribute>
+ <name>rowOnDblClick</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>Defines a JavaScript ondblclick event handler for each table row</description>
+ </attribute>
</tag>
<!-- inputHidden -->
@@ -2434,6 +2446,12 @@
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
+ <attribute>
+ <name>width</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>This attribute can be used to set the width of the <TD> elements</description>
+ </attribute>
</tag>
</taglib>