Re: Issue with the FileUploadField
Ha! I've never encountered this in recent versions of Wicket (6 & 7) as I've never needed to upload files on those projects. My question concerned an old legacy app I need to extend running in 1.3.7 (!). So my options are migrate to 7 (no time and not worth it), figure out the iframes trick referred to in other posts, give up modals. So I don't want to spend any time on this so I just reworked the interface to use a SubmitLink from a non-modal panel. Thanks anyway! CN -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Issue-with-the-FileUploadField-tp1868606p4674888.html Sent from the Users forum 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: Issue with the FileUploadField
Hi CN, I would expect it to simply work, as wicket transparently handles this. So what exactly is unclear for you? Perhaps I can help you with that. How we do it: we have a panel which contains a form, which in turn contains a FileUploadField. We have an ajax submit button in the form, and handle the upload on ajax submit. Met vriendelijke groet, Kind regards, Bas Gooren Op 13 juni 2016 bij 17:20:28, ChambreNoire (a...@tentelemed.com) schreef: Hey there, Little late in the day, but I'm trying to find a working example of a simple ajax fileuploadfield to be used within a modal window. A lot of post refer to http://www.dooriented.com/blog/2008/04/23/wicket-ajax-like-file-upload-on-a-modal-window/ however this link is dead and I couldn't find a cached version. If anyone could point me towards a working example I'd really appreciate that! Thanks CN -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Issue-with-the-FileUploadField-tp1868606p4674879.html Sent from the Users forum 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: Issue with the FileUploadField
Hey there, Little late in the day, but I'm trying to find a working example of a simple ajax fileuploadfield to be used within a modal window. A lot of post refer to http://www.dooriented.com/blog/2008/04/23/wicket-ajax-like-file-upload-on-a-modal-window/ however this link is dead and I couldn't find a cached version. If anyone could point me towards a working example I'd really appreciate that! Thanks CN -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Issue-with-the-FileUploadField-tp1868606p4674879.html Sent from the Users forum 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: Issue with the FileUploadField
The trick is based on a hidden iframe, like the following: iframe id=upload_target wicket:id=upload_target name=upload_target style=width:0px;height:0px;border:0 /iframe form wicket:id=form0 target=upload_target div id=upload-field-handler style=position: absolute; z-index: 100; display: none input id=upload_field wicket:id=upload_field type=file class=DisplayText size=55 onchange=upload(this) / /div /form And tell wicket to do not redirect on form upload when the submit is terminated: public void onSubmit() { getRequestCycle().setRedirect(false); getRequestCycle().setRequestTarget(EmptyRequestTarget.getInstance()); } I'm attaching my code so you can check details. Have fun -- Paolo On Wed, Jul 9, 2008 at 4:35 PM, Arun Wagle [EMAIL PROTECTED] wrote: Hello All, I have an issue with the file upload I have a Fileupload input filed on a tabbed panel. The first time when I select a file and submit, the following returns null FileUpload upload = fileUploadField.getFileUpload(); return null. But if I select the same file again and submit I get the value. Have anyone encountered this before ? If this can be of any help, the TabbedPanel link is a AJAXSubmit as I need to retain some of the form values on tab change . Also the above action occurs on the submit of another File Upload button on the form and not on the Tabbed link Submit Also is there a AJAX Fileupload component anyone know of or has written? . Thank you all in advance Regards, Arun Wagle package org.fao.ocd.applications.coin.web.ui.widget; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.fao.ocd.applications.coin.web.wicket.AjaxUtils; import org.apache.wicket.ajax.AjaxEventBehavior; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.IAjaxCallDecorator; import org.apache.wicket.ajax.calldecorator.AjaxCallDecorator; import org.apache.wicket.feedback.FeedbackMessage; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.upload.FileUpload; import org.apache.wicket.markup.html.form.upload.FileUploadField; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.request.target.basic.EmptyRequestTarget; import org.apache.wicket.util.lang.Bytes; /** * A specialized Panel aimed at file uploading management. * * pThe components to render the attachments list should look like this:br/ * code * lt;div wicket:id=attachment_container gt;br/ * lt;table id=attach-tablegt;br/ * lt;tr wicket:id=attachments gt;br/ *lt;td class=menuListItemgt;lt;img wicket:id=clip height=15 width=15 /gt; lt;/tdgt;br/ *lt;td class=menuListItemgt;lt;a wicket:id=link gt;lt;span wicket:id=filename gt;filename (size)lt;/spangt;lt;/agt;lt;/tdgt;br/ *lt;td class=menuListItemgt;lt;a wicket:id=delete gt;deletelt;/agt;lt;/tdgt;br/ * lt;/trgt;br/ * lt;/tablegt;br/ * lt;/divgt;br/ * lt;div id=upload-field-position class=menuListItem style=height: 22px gt;br/ * lt;a id=attach-link href=javascript:void(0) onclick=showUploadField(); gt;Attach a filelt;/agt;br/lt;/divgt; br/ * /code * /p * p * There are a few naming contraints you need to follow to make it work, due to the fact that some components' names are explicitly referenced in the Javascript code * contained in UploadPanel.html:br/ * 1) the last DIV in the code above must have id=upload-field-position;br/ * 2) the anchor inside it must have id=attach-link and onclick=showUploadField();. * /p * * @author Fabio Fioretti * */ public class UploadPanel extends Panel{ private static final Log log = LogFactory.getLog(UploadPanel.class); private UploadForm uploadForm; public UploadPanel(String id) { super(id); // the hidden frame createUploadTargetFrame(this); /* * The uploading form */ add( uploadForm = new UploadForm(form0) ); } public UploadPanel(String id, int sizeMB) { super(id); // the hidden frame createUploadTargetFrame(this); /* * The uploading form */ add( uploadForm = new UploadForm(form0, sizeMB) ); } private WebMarkupContainer createUploadTargetFrame(Panel container) { WebMarkupContainer frame = new WebMarkupContainer(upload_target); frame.add( new AjaxEventBehavior(onload) { protected IAjaxCallDecorator getAjaxCallDecorator() { return new AjaxCallDecorator() { public CharSequence decorateScript( CharSequence script ) { return if(__cload++0) { +script+ } ; } }; } protected void onEvent(AjaxRequestTarget target) { try { if( uploadForm.error != null ) { AjaxUtils.alert(target, String.valueOf(uploadForm.error.getMessage()) ); // on error we will reload the form target.addComponent( uploadForm ); // clear raising error uploadForm.error = null; } else { // on hidden frame reload we will refresh
Issue with the FileUploadField
Hello All, I have an issue with the file upload I have a Fileupload input filed on a tabbed panel. The first time when I select a file and submit, the following returns null FileUpload upload = fileUploadField.getFileUpload(); return null. But if I select the same file again and submit I get the value. Have anyone encountered this before ? If this can be of any help, the TabbedPanel link is a AJAXSubmit as I need to retain some of the form values on tab change . Also the above action occurs on the submit of another File Upload button on the form and not on the Tabbed link Submit Also is there a AJAX Fileupload component anyone know of or has written? . Thank you all in advance Regards, Arun Wagle
Re: Issue with the FileUploadField
Hello Arun, For the Ajax file upload, check out http://www.dooriented.com/blog/2008/04/23/wicket-ajax-like-file-upload-on-a-modal-window/ Cristi Manole On Wed, Jul 9, 2008 at 5:35 PM, Arun Wagle [EMAIL PROTECTED] wrote: Hello All, I have an issue with the file upload I have a Fileupload input filed on a tabbed panel. The first time when I select a file and submit, the following returns null FileUpload upload = fileUploadField.getFileUpload(); return null. But if I select the same file again and submit I get the value. Have anyone encountered this before ? If this can be of any help, the TabbedPanel link is a AJAXSubmit as I need to retain some of the form values on tab change . Also the above action occurs on the submit of another File Upload button on the form and not on the Tabbed link Submit Also is there a AJAX Fileupload component anyone know of or has written? . Thank you all in advance Regards, Arun Wagle
Re: Issue with the FileUploadField
Hello, Thanx for the reply, we are not planning to use IFrames for now. Anyways the first problem does not get solved even if I use Iframes. Any ideas ?? Regards, Arun Wagle On Wed, Jul 9, 2008 at 10:42 AM, Cristi Manole [EMAIL PROTECTED] wrote: Hello Arun, For the Ajax file upload, check out http://www.dooriented.com/blog/2008/04/23/wicket-ajax-like-file-upload-on-a-modal-window/ Cristi Manole On Wed, Jul 9, 2008 at 5:35 PM, Arun Wagle [EMAIL PROTECTED] wrote: Hello All, I have an issue with the file upload I have a Fileupload input filed on a tabbed panel. The first time when I select a file and submit, the following returns null FileUpload upload = fileUploadField.getFileUpload(); return null. But if I select the same file again and submit I get the value. Have anyone encountered this before ? If this can be of any help, the TabbedPanel link is a AJAXSubmit as I need to retain some of the form values on tab change . Also the above action occurs on the submit of another File Upload button on the form and not on the Tabbed link Submit Also is there a AJAX Fileupload component anyone know of or has written? . Thank you all in advance Regards, Arun Wagle