Пример #1
0
 static final String evalString(ValueExpression expr, FacesContext context) {
   try {
     return (String) expr.getValue(context.getELContext());
   } catch (ELException e) {
     throw new FacesException(e);
   }
 }
Пример #2
0
 static final int evalInt(ValueExpression expr, FacesContext context) {
   try {
     return (Integer) expr.getValue(context.getELContext());
   } catch (ELException e) {
     throw new FacesException(e);
   }
 }
Пример #3
0
  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);
  }
Пример #4
0
  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);
    }
  }
Пример #5
0
  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);
  }