예제 #1
0
  @Override
  public FormRowSet formatData(FormData formData) {
    FormRowSet rowSet = null;

    // get value
    String id = getPropertyString(FormUtil.PROPERTY_ID);
    if (id != null) {
      String[] values = FormUtil.getElementPropertyValues(this, formData);
      if (values != null && values.length > 0) {
        // check for empty submission via parameter
        String[] paramValues = FormUtil.getRequestParameterValues(this, formData);
        if ((paramValues == null || paramValues.length == 0)
            && FormUtil.isFormSubmitted(this, formData)) {
          values = new String[] {""};
        }

        // formulate values
        String delimitedValue = FormUtil.generateElementPropertyValues(values);

        // set value into Properties and FormRowSet object
        FormRow result = new FormRow();
        result.setProperty(id, delimitedValue);
        rowSet = new FormRowSet();
        rowSet.add(result);
      }
    }

    return rowSet;
  }
예제 #2
0
  @Override
  public String renderTemplate(FormData formData, Map dataModel) {
    String template = "selectBox.ftl";

    // set value
    String[] valueArray = FormUtil.getElementPropertyValues(this, formData);
    List<String> values = Arrays.asList(valueArray);
    dataModel.put("values", values);

    // set options
    Collection<Map> optionMap = getOptionMap(formData);
    dataModel.put("options", optionMap);

    String html = FormUtil.generateElementHtml(this, formData, template, dataModel);
    return html;
  }