the problem is that you cannot upload a file by means of ajax. you'll have to
use something like a hidden iframe that takes care of the file upload. as
far as i know this topic has already been discussed on the mailing list, i
also think in the wicketstuff (or wicket extensions) project there's an
attempt to do the iframe thingy ... but i'm not sure

regards, 
Michael

Doug Leeper wrote:
> 
> I just recently upgraded to 1.3.3 from 1.3.2 as there was a bug that was
> fixed in 1.3.2 (https://issues.apache.org/jira/browse/WICKET-1442) that I
> was getting.
> 
> However, in my AjaxButton.onSubmit( AjaxRequestTarget target, Form form )
> when I call my FileUploadField.getFileUpload() it is always null.
> 
> Any suggestions?
> 
> Note: I  submitting my form in a ModalWindow.
> 
> Here is my code:
> 
> public class NewImageTransformPanel extends LocalBasePanel {
> 
>       private FileUploadField fileUpload;
>       private ImageTransform image;
> 
> 
>       public NewImageTransformPanel(final ModalWindow window,
>                       final Integer campaignId) {
>               super(window.getContentId());
> 
>               image = new ImageTransform();
> 
>               Form form = new Form("transformForm");
>               form.setOutputMarkupId(true);
>               add(form);
>               form.add(new 
> PTFeedbackPanel("feedback").setOutputMarkupId(true));
> 
>               form.setModel(new CompoundPropertyModel(image));
>               
>               form.add( new RequiredTextField( "imageFileName" ));
> 
>               fileUpload = new FileUploadField("imageFile");
>               form.setMultiPart( true );
>               form.add(fileUpload);
> 
> 
>               form.add(new AjaxButton("addTransform") {
>                       public void onSubmit(AjaxRequestTarget target, Form 
> form) {
>                               try {
>                                       String fileName = 
> fileUpload.getFileUpload()
>                                                       .getClientFileName();   
> <=== NPE every time
>                                       String contentType = 
> fileUpload.getFileUpload()
>                                                       .getContentType();
>                                       byte[] content = 
> fileUpload.getFileUpload().getBytes();
> 
>                                       if (StoredImage.isAllowed(contentType) 
> == false) {
>                                               error("File type is not 
> supported. "
>                                                               + "Supported 
> types are JPEG, GIF, and PNG.");
>                                               target.addComponent(form);
>                                               return;
>                                       }
> 
>                                       image.setImageContentType(contentType);
>                                       image.setImageContent(content);
> 
>                                       
> CampaignMgr.getInstance().addImageTransform(campaignId,
>                                                       image);
>                                       info("Image transformation was added 
> successfully.");
>                                       window.close(target);
>                               } catch (Exception e) {
>                                       e.printStackTrace();
>                                       error(e);
>                                       target.addComponent(form);
>                               }
>                       }
> 
>                       @Override
>                       protected void onError(AjaxRequestTarget target, Form 
> form) {
>                               target.addComponent(form);
>                       }
> 
>               });
> 
>               form.add(new AjaxLink("cancel") {
>                       public void onClick(AjaxRequestTarget target) {
>                               window.close(target);
>                       }
>               });
>       }
> 
> }
> 


-----
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
View this message in context: 
http://www.nabble.com/Form-submit-with-a-FileUploadField-appears-not-to-work-in-a-Modal-Window-tp16795627p16795638.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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

Reply via email to