Author: alexsmirnov
Date: 2008-05-28 14:25:43 -0400 (Wed, 28 May 2008)
New Revision: 8812
Modified:
trunk/framework/api/src/main/java/org/ajax4jsf/application/StateHolder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateHolder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/LRUMap.java
Log:
change state saving behavior to meet a JSF 1.2 spec
Modified: trunk/framework/api/src/main/java/org/ajax4jsf/application/StateHolder.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/application/StateHolder.java 2008-05-28
17:47:30 UTC (rev 8811)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/application/StateHolder.java 2008-05-28
18:25:43 UTC (rev 8812)
@@ -2,8 +2,8 @@
public interface StateHolder {
- public Object getState(String viewId, String sequence);
+ public Object[] getState(String viewId, String sequence);
- public void saveState(String viewId, String sequence, Object state);
+ public void saveState(String viewId, String sequence, Object state[]);
}
\ No newline at end of file
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateHolder.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateHolder.java 2008-05-28
17:47:30 UTC (rev 8811)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateHolder.java 2008-05-28
18:25:43 UTC (rev 8812)
@@ -27,12 +27,12 @@
private static final long serialVersionUID = 6414488517358423537L;
private static final String STATE_HOLDER = AjaxStateHolder.class.getName();
- private final LRUMap<String,LRUMap<String, Object>> views;
+ private final LRUMap<String,LRUMap<String, Object[]>> views;
private final int numberOfViews;
private AjaxStateHolder(int capacity, int numberOfViews) {
- views = new LRUMap<String,LRUMap<String, Object>>(capacity);
+ views = new LRUMap<String,LRUMap<String, Object[]>>(capacity);
this.numberOfViews = numberOfViews;
}
@@ -75,23 +75,23 @@
/* (non-Javadoc)
* @see org.ajax4jsf.application.StateHolder#getState(java.lang.String,
java.lang.Object)
*/
- public Object getState(String viewId, String sequence) {
+ public Object[] getState(String viewId, String sequence) {
if (null == viewId) {
throw new NullPointerException(
"viewId parameter for get saved view state is null");
}
- Object state = null;
+ Object state[] = null;
synchronized (views) {
- LRUMap<String,Object> viewVersions = views.get(viewId);
+ LRUMap<String,Object[]> viewVersions = views.get(viewId);
if (null != viewVersions) {
if (null != sequence) {
state = viewVersions.get(sequence);
}
if (null == state) {
if (_log.isDebugEnabled()) {
- _log.debug("No saved view state for sequence "+sequence+", use most
recent");
+ _log.debug("No saved view state for sequence "+sequence);
}
- state = viewVersions.getMostRecent();
+// state = viewVersions.getMostRecent();
}
} else if (_log.isDebugEnabled()) {
_log.debug("No saved view states for viewId "+viewId);
@@ -103,7 +103,7 @@
/* (non-Javadoc)
* @see org.ajax4jsf.application.StateHolder#saveState(java.lang.String,
java.lang.Object, java.lang.Object)
*/
- public void saveState(String viewId, String sequence, Object state) {
+ public void saveState(String viewId, String sequence, Object[] state) {
if (null == viewId) {
throw new NullPointerException(
"viewId parameter for save view state is null");
@@ -117,10 +117,10 @@
_log.debug("Save new viewState in session for viewId "+viewId+" and
sequence "+sequence);
}
synchronized (views) {
- LRUMap<String,Object> viewVersions = views.get(viewId);
+ LRUMap<String,Object[]> viewVersions = views.get(viewId);
if (null == viewVersions) {
// TODO - make size parameter configurable
- viewVersions = new LRUMap<String,Object>(this.numberOfViews);
+ viewVersions = new LRUMap<String,Object[]>(this.numberOfViews);
views.put(viewId, viewVersions);
}
viewVersions.put(sequence, state);
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2008-05-28
17:47:30 UTC (rev 8811)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2008-05-28
18:25:43 UTC (rev 8812)
@@ -245,7 +245,7 @@
String viewId, String renderKitId) {
String id = restoreLogicalViewId(context, viewId, renderKitId);
StateHolder stateHolder = getStateHolder(context);
- Object[] restoredState = (Object[]) stateHolder.getState(viewId, id);
+ Object[] restoredState = stateHolder.getState(viewId, id);
return restoredState;
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/util/LRUMap.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/LRUMap.java 2008-05-28 17:47:30
UTC (rev 8811)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/LRUMap.java 2008-05-28 18:25:43
UTC (rev 8812)
@@ -40,9 +40,9 @@
* Get most recent used element
* @return the most Recent value
*/
- public Object getMostRecent() {
+ public V getMostRecent() {
Iterator<V> iterator = values().iterator();
- Object mostRecent=null;
+ V mostRecent=null;
while (iterator.hasNext()) {
mostRecent = iterator.next();