public void restoreState(FacesContext context,
Object state) {
if (context == null) {
throw new NullPointerException();
}
// if we have state
if (null == state) {
return;
}
if (!(state instanceof MethodBinding)) {
Object [] stateStruct = (Object []) state;
Object savedState = stateStruct[0];
String className = stateStruct[1].toString();
MethodBinding result = null;
Class toRestoreClass;
if (null != className) {
try {
toRestoreClass = loadClass(className, this);
}
catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
if (null != toRestoreClass) {
try {
result =
(MethodBinding) toRestoreClass.newInstance();
}
catch (InstantiationException e) {
throw new IllegalStateException(e);
}
catch (IllegalAccessException a) {
throw new IllegalStateException(a);
}
}
if (null != result && null != savedState) {
// don't need to check transient, since that was
// done on the saving side.
((StateHolder)result).restoreState(context, savedState);
}
methodBinding = result;
}
}
else {
methodBinding = (MethodBinding) state;
}
}
|