Author: nbelaevski
Date: 2007-10-12 12:17:40 -0400 (Fri, 12 Oct 2007)
New Revision: 3348
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
Log:
http://jira.jboss.com/jira/browse/RF-980
Modified: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2007-10-12
16:10:06 UTC (rev 3347)
+++
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2007-10-12
16:17:40 UTC (rev 3348)
@@ -76,12 +76,8 @@
return ((StackEntry) stackEntries.getLast()).model;
}
- return null;
- //FIXME: Maksim: Handle deleted entries correctly
-/*
throw new IllegalStateException(
"No tree element available or row key not set!");
-*/
}
public boolean isEmpty() {
@@ -226,12 +222,9 @@
if (isRowAvailable()) {
return null;
}
- return null;
- //FIXME: Maksim: Handle deleted entries correctly
-/*
+
throw new IllegalStateException(
"No tree element available or row key not set!");
-*/
}
/*
@@ -252,12 +245,9 @@
return true;
}
- return true;
- //FIXME: Maksim: Handle deleted entries correctly
-/*
+
throw new IllegalStateException(
"No tree element available or row key not set!");
-*/
}
protected StackingTreeModel getRoot() {
@@ -491,12 +481,8 @@
return lastEntry.model.rowData;
}
- return null;
- //FIXME: Maksim: Handle deleted entries correctly
- /*
throw new IllegalStateException(
"No tree element available or row key not set!");
- */
}
/*
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2007-10-12
16:10:06 UTC (rev 3347)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2007-10-12
16:17:40 UTC (rev 3348)
@@ -259,22 +259,34 @@
public void setRowIndex(int index) {
FacesContext faces = FacesContext.getCurrentInstance();
ExtendedDataModel localModel = getExtendedDataModel();
+
+ boolean rowAvailable = isRowAvailable();
+
// if(key == localModel.getRowIndex()){
// return;
// }
- // save child state
- this.saveChildState(faces);
+
+ if (rowAvailable) {
+ // save child state
+ this.saveChildState(faces);
+ }
+
// Set current model row by int, but immediately get value from model.
// for compability, complex models must provide values map between
// integer and key value.
localModel.setRowIndex(index);
+
this._rowKey = localModel.getRowKey();
this._clientId = null;
- boolean rowSelected = this._rowKey != null;
+
+ boolean rowSelected = this._rowKey != null && rowAvailable;
setupVariable(faces, localModel, rowSelected);
- // restore child state
- this.restoreChildState(faces);
+
+ if (rowAvailable) {
+ // restore child state
+ this.restoreChildState(faces);
+ }
}
/*
@@ -312,18 +324,28 @@
*/
public void setRowKey(FacesContext faces, Object key) {
ExtendedDataModel localModel = getExtendedDataModel();
- // save child state
- this.saveChildState(faces);
+
+ boolean rowAvailable = isRowAvailable();
+
+ if (rowAvailable) {
+ // save child state
+ this.saveChildState(faces);
+ }
+
this._rowKey = key;
this._clientId = null;
+
localModel.setRowKey(key);
- boolean rowSelected = key != null;
+ boolean rowSelected = key != null && rowAvailable;
+ //XXX check for row availability
setupVariable(faces, localModel, rowSelected);
- // restore child state
- this.restoreChildState(faces);
-
+
+ if (rowAvailable) {
+ // restore child state
+ this.restoreChildState(faces);
+ }
}
/*
@@ -485,6 +507,8 @@
* component state will be put into request scope attributes with names
* given by "var" and "varState" bean properties.
*
+ * Changed: does not check for row availability now
+ *
* @param faces
* current faces context
* @param localModel
@@ -493,7 +517,7 @@
protected void setupVariable(FacesContext faces, DataModel localModel,
boolean rowSelected) {
Map attrs = faces.getExternalContext().getRequestMap();
- if (rowSelected && isRowAvailable()) {
+ if (rowSelected/*&& isRowAvailable()*/) {
// Current row data.
setupVariable(getVar(), attrs, localModel.getRowData());
// Component state variable.