Re: IOException: The handle is invalid - on file upload
After more investigation, the problems were coming from trying to run the upload in a separate thread. Once I move the code back into the main thread where the onSubmit is pressed it all works fine. Is it possible to have the upload process take place in a separate thread, so the user can continue working while the upload takes place? Andrew Moore wrote: Just to follow this up. When using the inputstream and the read() method on the same upload file. The number of lines read before getting in error message changes each time. Could it be a jdk bug? Andrew Moore wrote: I'm using wicket 1.3.4 and doing some file uploading and keep intermittantly getting the following error: IOException: The handle is invalid. My form is uploads zips and jpgs and is very similar to the wicket examples. ie in my submit button I do the following: if (uploadFile != null) { // Check new file, delete if it already existed imageProcessing.deleteFileIfExists(uploadFolder + File.separator + uploadFile.getClientFileName()); // Create a new file File newFile = new File(uploadFolder, uploadFile.getClientFileName()); try { // Save to new file newFile.createNewFile(); uploadFile.writeTo(newFile); }... It's the writeTo line that causes the error. Some jpgs and zips work fine, others don't or only intermittantly work. An example image I'm having errors with is this one: http://transfer.folioflow.com.s3.amazonaws.com/08092007045.jpg I've tried using the getInputStream() instead of the writeTo, and tried writing the inputstream into an output stream, but get exactly the same error while doing an inputstream.read(); I'm at a bit of a loss to what could be causing this. -- View this message in context: http://www.nabble.com/IOException%3A-The-handle-is-invalid---on-file-upload-tp18998030p19028996.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]
Using FileUpload.writeTo() in a background thread
I'm doing a file uploading screen, where some of the files can be quite large (up to 30mb) and am therefore hoping to be able to process the actual upload in a separate thread to the screen. All my post processing on the file that takes place works fine in a separate thread, but if I try to do the writing of the file with a FileUpload.writeTo() I get an IO exception that the file handle is invalid. Is what I'm trying to do possible? I'm guessing that the file handle is getting closed or lost as the upload page finishes. If it's not possible with the writeTo method, is there any other way of doing this? See example below. Thanks Andrew Example: OnSubmit (ie upload button) = public void onSubmit() { final FileUpload upload = uploadField.getFileUpload(); if (upload != null){ File newFile = new File(uploadFolder, upload.getClientFileName()); // create the new file newFile.createNewFile(); /* works if uploadFile.writeTo(newFile); is done here */ final ImportThread it = new ImportThread(getMySession(), upload, uploadFolder, newFile); it.start(); } } Separate thread: private static class ImportThread extends Thread { private final SignInSession session; private final FileUpload uploadFile; private final Folder uploadFolderThread; private File newFile; public ImportThread(SignInSession session, FileUpload uploadFile, Folder uploadFolderThread, File newFile) { logger.debug(long running thread constructor); this.session = session; this.uploadFile = uploadFile; this.uploadFolderThread = uploadFolderThread; this.newFile = newFile; this.filename = filename; } public void run() { logger.debug(long running thread run); uploadFile.writeTo(newFile); /* causes invalid file handle when run in thread */ //other post processing here } } -- View this message in context: http://www.nabble.com/Using-FileUpload.writeTo%28%29-in-a-background-thread-tp19030588p19030588.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]
IOException: The handle is invalid - on file upload
I'm using wicket 1.3.4 and doing some file uploading and keep intermittantly getting the following error: IOException: The handle is invalid. My form is uploads zips and jpgs and is very similar to the wicket examples. ie in my submit button I do the following: if (uploadFile != null) { // Check new file, delete if it already existed imageProcessing.deleteFileIfExists(uploadFolder + File.separator + uploadFile.getClientFileName()); // Create a new file File newFile = new File(uploadFolder, uploadFile.getClientFileName()); try { // Save to new file newFile.createNewFile(); uploadFile.writeTo(newFile); }... It's the writeTo line that causes the error. Some jpgs and zips work fine, others don't or only intermittantly work. An example image I'm having errors with is this one: http://transfer.folioflow.com.s3.amazonaws.com/08092007045.jpg I've tried using the getInputStream() instead of the writeTo, and tried writing the inputstream into an output stream, but get exactly the same error while doing an inputstream.read(); I'm at a bit of a loss to what could be causing this. -- View this message in context: http://www.nabble.com/IOException%3A-The-handle-is-invalid---on-file-upload-tp18998030p18998030.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]
Re: IOException: The handle is invalid - on file upload
Just to follow this up. When using the inputstream and the read() method on the same upload file. The number of lines read before getting in error message changes each time. Could it be a jdk bug? Andrew Moore wrote: I'm using wicket 1.3.4 and doing some file uploading and keep intermittantly getting the following error: IOException: The handle is invalid. My form is uploads zips and jpgs and is very similar to the wicket examples. ie in my submit button I do the following: if (uploadFile != null) { // Check new file, delete if it already existed imageProcessing.deleteFileIfExists(uploadFolder + File.separator + uploadFile.getClientFileName()); // Create a new file File newFile = new File(uploadFolder, uploadFile.getClientFileName()); try { // Save to new file newFile.createNewFile(); uploadFile.writeTo(newFile); }... It's the writeTo line that causes the error. Some jpgs and zips work fine, others don't or only intermittantly work. An example image I'm having errors with is this one: http://transfer.folioflow.com.s3.amazonaws.com/08092007045.jpg I've tried using the getInputStream() instead of the writeTo, and tried writing the inputstream into an output stream, but get exactly the same error while doing an inputstream.read(); I'm at a bit of a loss to what could be causing this. -- View this message in context: http://www.nabble.com/IOException%3A-The-handle-is-invalid---on-file-upload-tp18998030p18998188.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]
Re: AjaxSelfUpdatingTimerBahaviour to enable button when process compete
Thanks, that's just what I was looking for. Cheers Andrew Mr Mean wrote: You can override onPostProcessTarget of your AjaxSelfUpdatingTimerBehavior and enable your button there. Maurice On Sun, May 4, 2008 at 2:08 PM, Andrew Moore [EMAIL PROTECTED] wrote: Hi, I'm currently using an ajaxselfupdatingtimerbehaviour to update a message field for when a job is complete with the following code: final Label status = new Label(uploadstatus, new AbstractReadOnlyModel() { private static final long serialVersionUID = 938943178761943953L; public Object getObject() { if (getMySession().isUploading()) { return getString(uploading); } else if (getMySession().isUploadComplete()) { return getString(uploadcomplete); } else { return ; } } }); status.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5))); add(status); === What I'm wanting to also have happen is then when the session.isUploadComplete is true I want to be able to re-enable a button which got disabled when the process started. I just can't think what I need to do to my button: === final Button cancel = new Button(cancel, new StringResourceModel(cancelbutton, this, null)) { private static final long serialVersionUID = 691332069442892669L; public void onSubmit() { setReturnPage(pageId, pageType, website); } }; cancel.setDefaultFormProcessing(false); form.add(cancel); -- View this message in context: http://www.nabble.com/AjaxSelfUpdatingTimerBahaviour-to-enable-button-when-process-compete-tp17045416p17045416.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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/AjaxSelfUpdatingTimerBahaviour-to-enable-button-when-process-compete-tp17045416p17046752.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]
Re: Referencing images in javascript - wicket 1.3.1
Thanks, that's perfect. igor.vaynberg wrote: urlfor(new resourcereference(Panels.class, folder.gif)); -igor On Fri, Mar 28, 2008 at 1:11 AM, Andrew Moore [EMAIL PROTECTED] wrote: I'm using wicket 1.3.1 and have a javascript file which needs to reference some images. I'm using the following code in a panel to include the javascript with images: CharSequence folder = getRequest().getRelativePathPrefixToContextRoot() + folder.gif; PackagedTextTemplate js = new PackagedTextTemplate(PageTreePanel.class, folder-tree-static.js); Map map = new HashMap(); map.put(folder, folder); add(TextTemplateHeaderContributor.forJavaScript(js, new Model((Serializable)map))); Now, I can see that my ${folder} reference that I had in the javascript is getting replaced with the image file name, but the getRelativePathPrefixToContextRoot() returns ../ so the javascript image reference comes out as ../folder.gif I've tried to place the images all over the place, but cannot get it to find them. If I use firebug to manually edit the url to resources/com.example.web.page.Panels/folder.gif then the image shows. I just can't work out the correct way (or location) to place the image. Any help would be great. Thanks Andrew -- View this message in context: http://www.nabble.com/Referencing-images-in-javascript---wicket-1.3.1-tp16347523p16347523.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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Referencing-images-in-javascript---wicket-1.3.1-tp16347523p16392864.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]
wicket-datetime 1.3.1 css problem
I've just upgraded to wicket 1.3.1 and seem to be having a problem getting the calendar to display correctly. It works, but it's not picking up calendar css. From having a quick look at the source of AbstractCalendar is seems to be doing a: add(HeaderContributor.forCss(AbstractCalendar.class, assets/calendar.css)); but from what I can tell calendar.css doesn't seem to be under the assets directory assets it seems to be at assets/skins/sam. Am I doing something wrong, or is the css resource path not correct? Cheers Andrew -- View this message in context: http://www.nabble.com/wicket-datetime-1.3.1-css-problem-tp15731702p15731702.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]
Using ajax to update a panel
Hi, I've got a page, which includes a drop down choice box, and a panel (with a list of images). The drop down box holds an id (which ties back to a list of images), what I'm wanting to be able to do is that if the user changes the drop down choice, the panel refreshes via ajax with the new images. Here's a few snippets of code: - //insert the image preview panel final ImagePreviewPanel imagePreviewPanel = new ImagePreviewPanel(imagePreviewPanel, generalPage.getImageCollectionId()); imagePreviewPanel.setOutputMarkupId(true); form.add(imagePreviewPanel); form.setOutputMarkupId(true); //add the OnChange for the ajax call OnChangeAjaxBehavior onChangeAjaxBehavior = new OnChangeAjaxBehavior(){ protected void onUpdate(AjaxRequestTarget target) { FormComponent fc = getFormComponent(); fc.getForm(); GeneralPage aGeneralPage = (GeneralPage) fc.getForm().getModelObject(); //get the drop down image collection id if (aGeneralPage.getImageCollectionOption() != null){ String keyValue = aGeneralPage.getImageCollectionOption().getKey(); imagePreviewPanel.setImageCollectionId(new Long(aGeneralPage.getImageCollectionOption().getKey())); } target.addComponent(imagePreviewPanel); } }; - Then I've got the panel (which I've cut down on the details here to make it a bit easier to understand) - public class ImagePreviewPanel extends Panel { private Long imageCollectionId; private String galleryCounterText = ; private List imageList = new ArrayList(); public ImagePreviewPanel(final String componentId, Long anImageCollectionId){ super(componentId); //set up the instance variable from the constructor setImageCollectionId(anImageCollectionId); //now add the image previews //first get the images if there are any ImageCollection imageCollection = imageCollectionDao.findByImageCollectionId(imageCollectionId); WebMarkupContainer dataImagecontainer = new WebMarkupContainer(dataimage); dataImagecontainer.setOutputMarkupId(true); add(dataImagecontainer); //display the total number of images in the list galleryCounterText = imageCollection.getImages().size(); add(new Label(galleryCounter,new PropertyModel(this, galleryCounterText)).setOutputMarkupId(true)); //get the collection of images from the imageCollection object imageList = imageCollection.getImages(); final PageableListView imageView; dataImagecontainer.add(imageView = new PageableListView(galleryList, new CompoundPropertyModel(imageList), 20){ public void populateItem(final ListItem listItem){ final Image image = (Image)listItem.getModelObject(); //set up default image element description String imageElementDescription = new StringResourceModel(noImageElementDescription, this, null).getString(); //set up image element description if a better one exists StaticImage staticImage = new StaticImage(previewImage, image.getImageHref()); staticImage.setOutputMarkupId(true); listItem.add(staticImage); } }); imageView.setOutputMarkupId(true); } public Long getImageCollectionId() { return imageCollectionId; } public void setImageCollectionId(Long imageCollectionId) { this.imageCollectionId = imageCollectionId; } } - The only thing is, don't feel like I've got my head completely around the wicket models and I'm having trouble working out what I need to do to the page and panel to get the panel to refresh via ajax. Sorry for the amount of code, but it's the only way I think to try and describe what I've currently got. Thanks Andrew -- View this message in context: http://www.nabble.com/Using-ajax-to-update-a-panel-tf4949239.html#a14170394 Sent from the Wicket
Re: Using ajax to update a panel
The ajax stuff is firing (as I can see in the ajax debug window) but the panel does not get updated. I know I'm getting the id from the drop down and the ajax bit itself is fine as I can get the value of the drop down and append it to a test label on the form that's used to store the dropdown details. I think it's mostly my lack of understanding of what actually fires with the ajax call, as I need to be able to refresh the values from the database. Should I be creating a Model overriding the setObject to do this? wicket user wrote: Hi Andrew, So what's actually happening? Anything? Exceptions or does the image just stay the same? On 05/12/2007, Andrew Moore [EMAIL PROTECTED] wrote: Hi, I've got a page, which includes a drop down choice box, and a panel (with a list of images). The drop down box holds an id (which ties back to a list of images), what I'm wanting to be able to do is that if the user changes the drop down choice, the panel refreshes via ajax with the new images. Here's a few snippets of code: - //insert the image preview panel final ImagePreviewPanel imagePreviewPanel = new ImagePreviewPanel(imagePreviewPanel, generalPage.getImageCollectionId ()); imagePreviewPanel.setOutputMarkupId(true); form.add(imagePreviewPanel); form.setOutputMarkupId(true); //add the OnChange for the ajax call OnChangeAjaxBehavior onChangeAjaxBehavior = new OnChangeAjaxBehavior(){ protected void onUpdate(AjaxRequestTarget target) { FormComponent fc = getFormComponent(); fc.getForm(); GeneralPage aGeneralPage = (GeneralPage) fc.getForm().getModelObject(); //get the drop down image collection id if (aGeneralPage.getImageCollectionOption() != null){ String keyValue = aGeneralPage.getImageCollectionOption().getKey(); imagePreviewPanel.setImageCollectionId(new Long(aGeneralPage.getImageCollectionOption().getKey())); } target.addComponent(imagePreviewPanel); } }; - Then I've got the panel (which I've cut down on the details here to make it a bit easier to understand) - public class ImagePreviewPanel extends Panel { private Long imageCollectionId; private String galleryCounterText = ; private List imageList = new ArrayList(); public ImagePreviewPanel(final String componentId, Long anImageCollectionId){ super(componentId); //set up the instance variable from the constructor setImageCollectionId(anImageCollectionId); //now add the image previews //first get the images if there are any ImageCollection imageCollection = imageCollectionDao.findByImageCollectionId(imageCollectionId); WebMarkupContainer dataImagecontainer = new WebMarkupContainer(dataimage); dataImagecontainer.setOutputMarkupId(true); add(dataImagecontainer); //display the total number of images in the list galleryCounterText = imageCollection.getImages().size(); add(new Label(galleryCounter,new PropertyModel(this, galleryCounterText)).setOutputMarkupId(true)); //get the collection of images from the imageCollection object imageList = imageCollection.getImages(); final PageableListView imageView; dataImagecontainer.add(imageView = new PageableListView(galleryList, new CompoundPropertyModel(imageList), 20){ public void populateItem(final ListItem listItem){ final Image image = (Image)listItem.getModelObject(); //set up default image element description String imageElementDescription = new StringResourceModel(noImageElementDescription, this, null).getString(); //set up image element description if a better one exists StaticImage staticImage = new StaticImage(previewImage, image.getImageHref()); staticImage.setOutputMarkupId(true); listItem.add(staticImage); } }); imageView.setOutputMarkupId(true); } public Long getImageCollectionId() { return imageCollectionId; } public void setImageCollectionId(Long imageCollectionId
Re: Ajax Dojo Drag and Drop
Andrew Moore wrote: Hi, At the moment I have a list on a page using some code like below: form.add(imageView = new DataView(galleryList, imageCollection.getImages(),10){ public void populateItem(final ListItem listItem){ final Image image = (Image)listItem.getModelObject(); listItem.add(new Label(imageName, image.getImageName())); listItem.add(moveUpLink(moveUp, listItem)); listItem.add(moveDownLink(moveDown, listItem)); } }); datacontainer.add(new AjaxPagingNavigator(navigator, imageView)); I've been trying to look at the wicket stuff dojo drag and drop stuff, as what I would ideally like instead of having a moveUpLink and moveDownLink is the ability to drag and drop the order of items in the list. I've seen the demo's running at http://www.demay-fr.net:8080/Wicket-start/app, but the API don't seem to be the same as the ones in the latest wicket-stuff 1.3 dojo beta jar. How would I go about converting the above code into a list that can be reordered using drag and drop. Thanks Andrew Hi, At the moment I have a list on a page using some code like below: form.add(imageView = new DataView(galleryList, imageCollection.getImages(),10){ public void populateItem(final ListItem listItem){ final Image image = (Image)listItem.getModelObject(); listItem.add(new Label(imageName, image.getImageName())); listItem.add(moveUpLink(moveUp, listItem)); listItem.add(moveDownLink(moveDown, listItem)); } }); datacontainer.add(new AjaxPagingNavigator(navigator, imageView)); I've been trying to look at the wicket stuff dojo drag and drop stuff, as what I would ideally like instead of having a moveUpLink and moveDownLink is the ability to drag and drop the order of items in the list. I've seen the demo's running at http://www.demay-fr.net:8080/Wicket-start/app, but the API don't seem to be the same as the ones in the latest wicket-stuff 1.3 dojo beta jar. How would I go about converting the above code into a list that can be reordered using drag and drop. Thanks Andrew -- View this message in context: http://www.nabble.com/Ajax-Dojo-Drag-and-Drop-tf4776388.html#a13663619 Sent from the Wicket - User mailing list archive at Nabble.com.