Пример #1
0
  /**
   * @see com.tonbeller.wcf.convert.SelectConverterBase#updateModelReference(Formatter, Map,
   *     Element, Object)
   */
  protected void updateModelReference(Formatter fmt, Element elem, Object bean)
      throws FormatException, IllegalAccessException, NoSuchMethodException,
          InvocationTargetException {

    String model = SelectMultiple.getModelReference(elem);
    if (model.length() == 0) return;

    String type = SelectMultiple.getType(elem);
    String formatString = SelectMultiple.getFormatString(elem);
    FormatHandler parser = fmt.getHandler(type);
    if (parser == null) throw new FormatException("no handler found for type: " + type);

    List items = SelectMultiple.getSelectedItems(elem);
    checkRequired(fmt.getLocale(), elem, items.size() == 0);
    List values = new ArrayList();

    for (Iterator it = items.iterator(); it.hasNext(); ) {
      Element item = (Element) it.next();
      String valueString = Item.getValue(item);
      Object value = parser.parse(valueString, formatString);
      values.add(value);
    }

    PropertyUtils.setProperty(bean, model, parser.toNativeArray(values));
  }