Exemplo n.º 1
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);
  }
Exemplo n.º 2
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);
  }
Exemplo n.º 3
0
  private static String getMessage(FacesContext context, String messageId, String defaultMessage) {
    Application app = context.getApplication();

    String bundleName = app.getMessageBundle();

    if (bundleName == null) return defaultMessage;

    ResourceBundle bundle = app.getResourceBundle(context, bundleName);

    if (bundle == null) return defaultMessage;

    String msg = bundle.getString(messageId);

    if (msg != null) return msg;
    else return defaultMessage;
  }