Re: Form FileUploadField maxSize does not work
sounds like a bug, open a jira issue. -igor On Mon, Sep 7, 2009 at 1:10 AM, nytrus wrote: > > Yes the issue is that, the form being submitted is the outer (which has no > maxsize set, so default is used). > When I submit upload0, Form.handleMultiPart() is called on the outer form > (form0). > When I submit upload1, Form.handleMultiPart() is called on simpleUpload. > > I'm missing something or doing something wrong? > > > igor.vaynberg wrote: >> >> so is the problem that the form being submitted is the outer form and >> it doesnt support the inner form's maxsize? >> >> -igor >> > > -- > View this message in context: > http://www.nabble.com/Form-FileUploadField-maxSize-does-not-work-tp25293039p25326577.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form FileUploadField maxSize does not work
Yes the issue is that, the form being submitted is the outer (which has no maxsize set, so default is used). When I submit upload0, Form.handleMultiPart() is called on the outer form (form0). When I submit upload1, Form.handleMultiPart() is called on simpleUpload. I'm missing something or doing something wrong? igor.vaynberg wrote: > > so is the problem that the form being submitted is the outer form and > it doesnt support the inner form's maxsize? > > -igor > -- View this message in context: http://www.nabble.com/Form-FileUploadField-maxSize-does-not-work-tp25293039p25326577.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form FileUploadField maxSize does not work
so is the problem that the form being submitted is the outer form and it doesnt support the inner form's maxsize? -igor On Fri, Sep 4, 2009 at 9:10 AM, nytrus wrote: > > Yes igor, below there is the code, even if is not very short. > The issue is that when I click on upload1 button the submitting form is > form0 instead of simpleUpload. > Maybe I've bad-coded some part. > > /** the upload panel, very similar to the wicket example **/ > public class UploadFilePanel extends Panel { > /** > * Form for uploads. > */ > private class FileUploadForm extends Form implements > IFormVisitorParticipant{ > private FileUploadField fileUploadField; > public FileUploadForm(String name, IModel model, Bytes > maxSize){ > super(name); > // set this form to multipart mode > setMultiPart(true); > // Add one file input field > add(fileUploadField = new FileUploadField("fileInput", model)); > setMaxSize(maxSize); > } > > �...@override > protected void onSubmit(){ > final FileUpload upload = fileUploadField.getFileUpload(); > if (upload != null){ > // Create a new file > File newFile = new File(getUploadFolder(), > upload.getClientFileName()); > try{ > // Save to new file > newFile.createNewFile(); > upload.writeTo(newFile); > FileUploadForm.this.info("saved file: " + > upload.getClientFileName()); > } > catch (Exception e){} > } > } > } > > public UploadFilePanel(String id, Bytes maxSize) { > super(id); > > // Add simple upload form, which is hooked up to its feedback panel > by > // virtue of that panel being nested in the form. > if (maxSize==null) maxSize = Bytes.kilobytes(100); > final FileUploadForm simpleUploadForm = new > FileUploadForm("simpleUpload", new Model(null), maxSize); > add(simpleUploadForm); > > final FeedbackPanel uploadFeedback = new > FeedbackPanel("uploadFeedback", new ContainerFeedbackMessageFilter(this)); > add(uploadFeedback); > } > } > /** the panel html **/ > > > > > > > > > > > > /** the test page **/ > public class TestPage extends WebPage { > Form form0 = new Form("form0"); > UploadFilePanel upload0 = new UploadFilePanel("upload0", > Bytes.kilobytes(100)); > form0.add(upload0); /*** this upload DOES NOT check max size ***/ > add(form0); > > UploadFilePanel upload1 = new UploadFilePanel("upload1", > Bytes.kilobytes(100)); > add(upload1); /*** this upload DOES check max size ***/ > } > /** test page html **/ > > > > > > > > > > > igor.vaynberg wrote: >> >> perhaps if you showed your code it would be more clear. >> >> -igor >> > > -- > View this message in context: > http://www.nabble.com/Form-FileUploadField-maxSize-does-not-work-tp25293039p25297271.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form FileUploadField maxSize does not work
Yes igor, below there is the code, even if is not very short. The issue is that when I click on upload1 button the submitting form is form0 instead of simpleUpload. Maybe I've bad-coded some part. /** the upload panel, very similar to the wicket example **/ public class UploadFilePanel extends Panel { /** * Form for uploads. */ private class FileUploadForm extends Form implements IFormVisitorParticipant{ private FileUploadField fileUploadField; public FileUploadForm(String name, IModel model, Bytes maxSize){ super(name); // set this form to multipart mode setMultiPart(true); // Add one file input field add(fileUploadField = new FileUploadField("fileInput", model)); setMaxSize(maxSize); } @Override protected void onSubmit(){ final FileUpload upload = fileUploadField.getFileUpload(); if (upload != null){ // Create a new file File newFile = new File(getUploadFolder(), upload.getClientFileName()); try{ // Save to new file newFile.createNewFile(); upload.writeTo(newFile); FileUploadForm.this.info("saved file: " + upload.getClientFileName()); } catch (Exception e){} } } } public UploadFilePanel(String id, Bytes maxSize) { super(id); // Add simple upload form, which is hooked up to its feedback panel by // virtue of that panel being nested in the form. if (maxSize==null) maxSize = Bytes.kilobytes(100); final FileUploadForm simpleUploadForm = new FileUploadForm("simpleUpload", new Model(null), maxSize); add(simpleUploadForm); final FeedbackPanel uploadFeedback = new FeedbackPanel("uploadFeedback", new ContainerFeedbackMessageFilter(this)); add(uploadFeedback); } } /** the panel html **/ /** the test page **/ public class TestPage extends WebPage { Form form0 = new Form("form0"); UploadFilePanel upload0 = new UploadFilePanel("upload0", Bytes.kilobytes(100)); form0.add(upload0); /*** this upload DOES NOT check max size ***/ add(form0); UploadFilePanel upload1 = new UploadFilePanel("upload1", Bytes.kilobytes(100)); add(upload1); /*** this upload DOES check max size ***/ } /** test page html **/ igor.vaynberg wrote: > > perhaps if you showed your code it would be more clear. > > -igor > -- View this message in context: http://www.nabble.com/Form-FileUploadField-maxSize-does-not-work-tp25293039p25297271.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form FileUploadField maxSize does not work
perhaps if you showed your code it would be more clear. -igor On Fri, Sep 4, 2009 at 4:50 AM, Nicola Tucci wrote: > I'm working with a file upload, using > http://www.wicket-library.com/wicket-examples/upload/single as example. > > I've created an UploadPanel very similar to UploadPage.java of the example > (with the FileUploadForm form). > Well I've maxsize set to 100K and this check work if I add my uploadpanel to > the WebPage. > > But If I add the upload panel to a form, the check does not work anymore. > The difference is that without outer form, the submit button of the upload > panel belong to FileUploadForm (with maxSize set). > With the outer form, the resulting submitting form correspond to the outer > form. I don't understand this as I'm still clicking the same submit button > of FileUploadForm. In this way, the maxsize is the one set in the outer form > (which I don't want to set! I want to have my UploadPanel component with > maxsize passed as parameter). > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org