public Object restore(FacesContext context) throws IllegalStateException {
Object result = null;
Class toRestoreClass;
// if the Object to save implemented Serializable but not
// StateHolder
if (null == className && null != savedState) {
return savedState;
}
// if the Object to save did not implement Serializable or
// StateHolder
if (className == null) {
return null;
}
// else the object to save did implement StateHolder
try {
toRestoreClass = loadClass(className, this);
}
catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
if (null != toRestoreClass) {
try {
result = toRestoreClass.newInstance();
}
catch (InstantiationException e) {
throw new IllegalStateException(e);
}
catch (IllegalAccessException a) {
throw new IllegalStateException(a);
}
}
if (null != result && null != savedState &&
result instanceof StateHolder) {
// don't need to check transient, since that was done on
// the saving side.
((StateHolder) result).restoreState(context, savedState);
}
return result;
}
|