コード例 #1
0
  protected void setProperty(FacesBean bean, PropertyKey key, ValueExpression expression) {
    if (expression == null) return;

    if (expression.isLiteralText()) {
      bean.setProperty(key, expression.getValue(null));
    } else {
      bean.setValueExpression(key, expression);
    }
  }
コード例 #2
0
  /**
   * Set a property of type int[]. If the value is an EL expression, it will be stored as a
   * ValueExpression. Otherwise, it will parsed as a whitespace-separated series of ints. Null
   * values are ignored.
   */
  protected void setIntArrayProperty(FacesBean bean, PropertyKey key, ValueExpression expression) {
    if (expression == null) return;

    if (expression.isLiteralText()) {
      Object value = expression.getValue(null);
      if (value != null) {
        String[] strings = _parseNameTokens(value);
        final int[] ints;
        if (strings != null) {
          try {
            ints = new int[strings.length];
            for (int i = 0; i < strings.length; i++) {
              int j = Integer.parseInt(strings[i]);
              ints[i] = j;
            }
          } catch (NumberFormatException e) {
            _LOG.severe("CANNOT_CONVERT_INTO_INT_ARRAY", value);
            _LOG.severe(e);
            return;
          }
        }
      }
    } else {
      bean.setValueExpression(key, expression);
    }
  }
コード例 #3
0
  /**
   * Set a property of type java.lang.Number. If the value is an EL expression, it will be stored as
   * a ValueBinding. Otherwise, it will parsed with Integer.valueOf() or Double.valueOf() . Null
   * values are ignored.
   */
  protected void setNumberProperty(FacesBean bean, PropertyKey key, ValueExpression expression) {
    if (expression == null) return;

    if (expression.isLiteralText()) {
      Object value = expression.getValue(null);
      if (value != null) {
        if (value instanceof Number) {
          bean.setProperty(key, value);
        } else {
          String valueStr = value.toString();
          if (valueStr.indexOf('.') == -1) bean.setProperty(key, Integer.valueOf(valueStr));
          else bean.setProperty(key, Double.valueOf(valueStr));
        }
      }
    } else {
      bean.setValueExpression(key, expression);
    }
  }
コード例 #4
0
  /**
   * Set a property of type java.util.Date. If the value is an EL expression, it will be stored as a
   * ValueBinding. Otherwise, it will parsed as an ISO 8601 date (yyyy-MM-dd) and the time
   * components (hour, min, second, millisecond) maximized. Null values are ignored.
   */
  protected void setMaxDateProperty(FacesBean bean, PropertyKey key, ValueExpression expression) {
    if (expression == null) return;

    if (expression.isLiteralText()) {
      Date d = _parseISODate(expression.getValue(null));
      Calendar c = Calendar.getInstance();
      TimeZone tz = RequestContext.getCurrentInstance().getTimeZone();
      if (tz != null) c.setTimeZone(tz);
      c.setTime(d);
      // Original value had 00:00:00 for hours,mins, seconds now maximize those
      // to get the latest time value for the date supplied.
      c.set(Calendar.HOUR_OF_DAY, 23);
      c.set(Calendar.MINUTE, 59);
      c.set(Calendar.SECOND, 59);
      c.set(Calendar.MILLISECOND, 999);
      bean.setProperty(key, c.getTime());
    } else {
      bean.setValueExpression(key, expression);
    }
  }
コード例 #5
0
  protected String getIcon(UIComponent component, FacesBean bean) {
    // Support subclasses without support for overriding the icon
    if (_iconKey == null) return null;

    return toResourceUri(FacesContext.getCurrentInstance(), bean.getProperty(_iconKey));
  }
コード例 #6
0
 protected String getSearchDesc(UIComponent component, FacesBean bean) {
   return toString(bean.getProperty(_searchDescKey));
 }
コード例 #7
0
 protected Object getActionExpression(UIComponent component, FacesBean bean) {
   return bean.getProperty(_actionExpressionKey);
 }