@Override
  public List<HtmlInput<?>> getInputs() throws DatabaseException {
    // delegate to the formscreen
    List<HtmlInput<?>> inputs = this.getFormScreen().getNewRecordForm().getInputs();

    // remove not-null constraints
    for (HtmlInput<?> i : inputs) i.setNillable(true);

    // add the file input for csv
    FileInput csvInput = new FileInput("__csvdata");
    csvInput.setLabel("CSV file");
    csvInput.setTooltip("choose here your data in comma-separated format.");
    csvInput.setDescription("Select your CSV file here.");
    inputs.add(csvInput);

    return inputs;
  }
Exemplo n.º 2
0
  /** Calculates visible columns. Needed for downloads. */
  public List<String> getVisibleColumnNames() {
    // FIXME temporary fix because model not properly used
    // we should instead use getModel().getHiddenColumns().

    List<String> showColumns = new ArrayList<String>();
    try {
      HtmlForm f = getInputs(this.getEntityClass().newInstance(), false);

      for (HtmlInput<?> i : f.getInputs()) {
        if (!i.isHidden()) {
          // strip prefix = this.getEntityClass() + "_"
          String name = i.getName();
          name = name.substring(this.getEntityClass().getSimpleName().length() + 1);

          // then add _label using getSearchField() where needed
          showColumns.add(getSearchField(name));
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return showColumns;
  }