예제 #1
0
  @Override
  public String getAsString(FacesContext context, UIComponent component, Object value) {
    if ((context == null) || (component == null)) {
      throw new NullPointerException();
    }

    if (value == null) {
      return "";
    }

    String val = null;
    WidgetValues widgetValues = DojoServerFacesUtil.getWidgetValuesInstance(context, component);
    if (widgetValues != null) {
      if (value instanceof Integer)
        val = widgetValues.getDisplayedValue((Integer) value).toString();
      else {
        if (widgetValues.getFirst().getClass().equals(value.getClass())) {
          int valueIndex = widgetValues.getValueIndex(value);
          if (valueIndex != -1) {
            val = widgetValues.getDisplayedValue(valueIndex);
          } else {
            val = value.toString();
          }
        } else val = value.toString();
      }
    }
    return val;
  }
예제 #2
0
  @Override
  public Object getAsObject(FacesContext context, UIComponent component, String value) {

    if ((context == null) || (component == null)) {
      throw new NullPointerException();
    }

    if (value == null) {
      return null;
    }

    Integer obj = null;
    WidgetValues widgetValues = DojoServerFacesUtil.getWidgetValuesInstance(context, component);
    if (widgetValues != null) {
      obj = new Integer(widgetValues.getDisplayedValueIndex(value));
    }

    if ((Integer) obj == -1) {
      FacesMessage errMessage = new FacesMessage("Undefined value!");
      errMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
      throw new ConverterException(errMessage);
    }

    return obj;
  }