static final String evalString(ValueExpression expr, FacesContext context) {
   try {
     return (String) expr.getValue(context.getELContext());
   } catch (ELException e) {
     throw new FacesException(e);
   }
 }
 static final int evalInt(ValueExpression expr, FacesContext context) {
   try {
     return (Integer) expr.getValue(context.getELContext());
   } catch (ELException e) {
     throw new FacesException(e);
   }
 }
  static ValueExpression restore(Object value, Class type, FacesContext context) {
    if (value == null) return null;

    String expr = (String) value;

    Application app = context.getApplication();
    ExpressionFactory factory = app.getExpressionFactory();

    return factory.createValueExpression(context.getELContext(), expr, type);
  }
  static final boolean evalBoolean(ValueExpression expr, FacesContext context) {
    try {
      Object value = expr.getValue(context.getELContext());

      if (value == null) return false;
      else if (value instanceof Boolean) return ((Boolean) value).booleanValue();
      else if (value instanceof String) return "true".equalsIgnoreCase((String) value);
      else return false;
    } catch (ELException e) {
      throw new FacesException(e);
    }
  }
  static ValueExpression restoreWithType(Object value, FacesContext context) {
    if (value == null) return null;

    Object[] state = (Object[]) value;

    String expr = (String) state[0];
    Class type = (Class) state[1];

    Application app = context.getApplication();
    ExpressionFactory factory = app.getExpressionFactory();

    return factory.createValueExpression(context.getELContext(), expr, type);
  }