Exemplo n.º 1
0
  public void decode(Object input, WebuiRequestContext context) throws Exception {
    String[] values = context.getRequestParameterValues(getId());
    if (values == null) {
      value_ = null;
      for (SelectItem option : options_) {
        if (option instanceof SelectOption) ((SelectOption) option).setSelected(false);
        else if (option instanceof SelectOptionGroup) {
          for (SelectOption opt : ((SelectOptionGroup) option).getOptions()) {
            opt.setSelected(false);
          }
        }
      }
      return;
    }

    int i = 0;
    value_ = values[0];
    for (SelectItem item : options_) {
      if (item instanceof SelectOption) {
        if (i > -1 && ((SelectOption) item).getValue().equals(values[i])) {
          ((SelectOption) item).setSelected(true);
          if (values.length == ++i) i = -1;
        } else ((SelectOption) item).setSelected(false);
      } else if (item instanceof SelectOptionGroup) {
        for (SelectOption opt : ((SelectOptionGroup) item).getOptions()) {
          if (i > -1 && (opt).getValue().equals(values[i])) {
            (opt).setSelected(true);
            if (values.length == ++i) i = -1;
          } else {
            (opt).setSelected(false);
          }
        }
      }
    }
  }
Exemplo n.º 2
0
  public UIFormSelectBoxWithGroups setValue(String value) {
    value_ = value;
    for (SelectItem option : options_) {
      if (option instanceof SelectOption) {
        if (((SelectOption) option).getValue().equals(value_))
          ((SelectOption) option).setSelected(true);
        else ((SelectOption) option).setSelected(false);
      } else if (option instanceof SelectOptionGroup) {
        ((SelectOptionGroup) option).setValue(value);
      }
    }

    return this;
  }
Exemplo n.º 3
0
  public UIFormSelectBoxWithGroups setSelectedValues(String[] values) {
    for (SelectItem option : options_) {
      if (option instanceof SelectOption) {
        ((SelectOption) option).setSelected(false);
        for (String value : values) {
          if (value.equals(((SelectOption) option).getValue())) {
            ((SelectOption) option).setSelected(true);
            break;
          }
        }
      } else if (option instanceof SelectOptionGroup) {
        ((SelectOptionGroup) option).setSelectedValue(values);
      }
    }

    return this;
  }
Exemplo n.º 4
0
 @Override
 public void reset() {
   if (options_ == null || options_.size() < 1) return;
   for (SelectItem option : options_) {
     if (option instanceof SelectOption) ((SelectOption) option).setSelected(false);
     else if (option instanceof SelectOptionGroup) {
       ((SelectOptionGroup) option).reset();
     }
   }
   for (SelectItem option : options_) {
     if (option instanceof SelectOption) {
       value_ = ((SelectOption) option).getValue();
       ((SelectOption) option).setSelected(true);
       break;
     }
   }
 }