Hi The error is not a javascript error but a server side error which tapestry.js flashes at the top (in red color). You can verify it by looking at the stack trace.
The error clearly says that the file property is null. The property will be initialized when you are inside the ajaxformloop. But in the template I can't see the ajaxformloop. Where is it ? regards Taha On Sat, Jul 23, 2011 at 12:12 AM, fante <callebill...@gmail.com> wrote: > Thanks for you advice, it feels like im getting closer to what I want to > achieve. > Below I posted the Java/Tml for my Page. > (Initially I wanted this to be under components instead, but for clarity I > converted to a Page) > > It seems to render stuff, but I still get Javascript Errors when I try to > use it. > ---- ERROR---- > Failure reading parameter 'value' of component Index:ajaxupload: Property > 'file' (within property expression 'file.file', of > com.fante.pages.Index@1c8a395d) is null. > Communication with the server failed: Failure reading parameter 'value' of > component Index:ajaxupload: Property 'file' (within property expression > 'file.file', of com.fante.pages.Index@1c8a395d) is null. > ---------- > > I must admit, that I am not very proficient with Javascript. > Can you tell if Im on the right track here? > > > > > > package com.fante.components; > > public class Index { > > @Persist > @Property > private List<FileHolder> files; > > @Property > private FileHolder file; > > @Persist > private int nrFiles; > > public void beginRender() { > files = new ArrayList<FileHolder>(); > } > > > > @SuppressWarnings("rawtypes") > public ValueEncoder getEncoder() { > return new ValueEncoder<FileHolder>() { > > public String toClient(FileHolder value) { > > return value.getKey(); > } > > public FileHolder toValue(String keyAsString) { > Long key = new Long(keyAsString); > for (FileHolder holder : files) { > if (keyAsString.equalsIgnoreCase("" + holder.getKey())) > { > return holder; > } > } > throw new IllegalArgumentException("Received key \"" + key > + "\" which has no counterpart in this collection: " > + files); > } > }; > } > > FileHolder onAddRow() { > // Create a skeleton Person and add it to the displayed list with a > unique key > FileHolder newFileHolder = new FileHolder(); > files.add(newFileHolder); > > return newFileHolder; > } > > public class FileHolder { > private List<UploadedFile> file; > private String key; > > public FileHolder() { > file = new ArrayList<UploadedFile>(); > key = "" + nrFiles; > nrFiles++; > } > public List<UploadedFile> getFile() { > return file; > } > > public void setFile(List<UploadedFile> file) { > this.file = file; > } > public String getKey() { > return key; > } > public void setKey(String key) { > this.key = key; > } > > > } > } > In tml: > > <t:form> > > <t:submitnotifier> > ${file.key} <input t:type='tawus/ajaxupload' > t:maxfiles="1" class="file" t:value="file.file" /> <br/> > </t:submitnotifier> > <p:addRow> > <br/> > <t:addrowlink>Add a row</t:addrowlink> > </p:addRow> > > </t:form> > > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/T5-Dynamically-add-section-of-upload-files-in-form-tp4623273p4624251.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org