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);
                        }
                });
        }

}
-- 
View this message in context: 
http://www.nabble.com/Form-submit-with-a-FileUploadField-appears-not-to-work-tp16795627p16795627.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