Hi all,

I'm trying to write a page that mimics an email composition form. On
this form the user should be allowed to add any number of attachments (files).

My idea is to use an AjaxFormLoop and a file upload component inside. The problem is - I can't.

The loop needs an iterable to work over - ok - that is a list of UploadedFiles. But, the 'addRow' event says it needs to return a non-null value so that the loop can correctly use it. But - i don't have an uploaded file yet - i just want a new Upload component to render itself.

Second problem - how would I process the files at the end?

My code - so far:

public class Test {


@Property private List<UploadedFile> files = new ArrayList<UploadedFile>();

  @Property private UploadedFile currentValue;


@Property private DefaultPrimaryKeyEncoder<Integer, UploadedFile> encoder = new DefaultPrimaryKeyEncoder<Integer, UploadedFile>();

  @InjectComponent private Block newFileBlock;

  public int getNumOfFiles() {
    return files.size();
  }

  public void onSubmit() {
    // what do i do here?
  }

  public Block onAddRow() {
    return null; // what do i do here? this causes illegal state excepton
  }
}

Test.tml:

    <t:form>
<t:ajaxformloop source="files" value="currentValue" encoder="encoder">
        <t:submitnotifier>
          <t:upload t:id="currentValue" value="currentValue" />
          <t:removerowlink>remove</t:removerowlink>
        </t:submitnotifier>
        <t:parameter name="addRow">
          <t:addrowlink>Add a row</t:addrowlink>
        </t:parameter>
      </t:ajaxformloop>

      <div class="t-beaneditor-row">
         <input type="submit" value="Submit"/>
      </div>

    </t:form>

    <p>Number of strings (after submit): ${numOfFiles}</p>

    <t:grid source="files"/>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to