Hi, At http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/ you can see how to mount IResource (thru ResourceReference). Your IResource (even better extend AbstractResource) impl shoud do something like:
MultipartServletWebRequest multipartServletWebRequest = new MultipartServletWebRequestImpl(httpServletRequest, "", Bytes.MAX, ""); // to get the FileItem's use: multipartServletWebRequest.getFiles(); Your form should point to the mount point of this IResource. See above article for example. Also see http://www.petrikainulainen.net/programming/tips-and-tricks/wicket-https-tutorial-part-three-creating-a-secure-form-submit-from-a-non-secure-page/ About AjaxChannel - each Ajax** component and behavior has a method getChannel(). Override it and return AjaxChannel with different name for all Ajax components/behaviors which should not be serialized at the client side. On Tue, Jan 17, 2012 at 8:27 AM, malebu <[email protected]> wrote: > Martin, > > Would you be kind enough to give an example? > > I tried the following: > > ajaxSimpleUploadForm.add(new AjaxButton("uploadVideoSubmit") { > @Override > protected void onSubmit(AjaxRequestTarget target, Form<?> form) > { > > AbstractResourceStreamWriter writer = new > AbstractResourceStreamWriter() { > @Override > public void write(Response output) { > for(FileUpload upload : uploads) { > System.out.println(new Date() + ": "+" Start > Reading"); > try { > long size = upload.getSize(); > BufferedReader fileReader = new > BufferedReader(new InputStreamReader(upload.getInputStream())); > ByteArrayOutputStream os = new > ByteArrayOutputStream(); > int i; > int counter = 0; > while((i = fileReader.read()) != -1) { > counter ++; > os.write(i); > if(counter == 100) { > long osSize = os.size(); > int p = Float.valueOf((100 * osSize) > / size).intValue(); > counter = 0; > > if(p > percent) { > percent = p; > p = 0; > } > } > } > os.flush(); > os.close(); > System.out.println(new Date() + ": "+" File > read successfully"); > > } catch(IOException ie) { > VideoUploadPanel.this.error("There was a > problem uploading the file"); > } > } > } > }; > getRequestCycle().scheduleRequestHandlerAfterCurrent( > new ResourceStreamRequestHandler(writer); > .... > ... > } > > The progress bar still does't get updated. Here is the response.. Note the > delay of 8 seconds marked in bold? Thats when the file is getting uploaded. > > Tue Jan 17 02:21:38 EST 2012: Loading value.. > Tue Jan 17 02:21:39 EST 2012: Updating Component > Tue Jan 17 02:21:39 EST 2012: Loading value.. > Tue Jan 17 02:21:40 EST 2012: Updating Component > Tue Jan 17 *02:21:40 EST 2012*: Loading value.. > > Tue Jan 17 02:21:43 EST 2012: Start Reading > Tue Jan 17 02:21:48 EST 2012: File read successfully > > Tue Jan 17 *02:21:48 EST 2012*: Updating Component > Tue Jan 17 02:21:48 EST 2012: Loading value.. > Tue Jan 17 02:21:50 EST 2012: Updating Component > Tue Jan 17 02:21:50 EST 2012: Loading value.. > Tue Jan 17 02:21:51 EST 2012: Updating Component > Tue Jan 17 02:21:51 EST 2012: Loading value.. > Tue Jan 17 02:21:52 EST 2012: Updating Component > > > Any help / example would really be a life saver. I couldnt find much example > online on IResource and AjaxChannel > > -Milton > > > Martin Grigorov-4 wrote >> >> Hi, >> >> I think the Ajax calls are serialized. >> The page instance can be used by a single request at any time. >> So you submit the form and this request acquires the lock on the page. >> AjaxSelfTimerUpdatingBehavior cannot use the page until the first >> request unlock it. >> Additionally the Ajax calls are serialized at the client side >> (JavaScript). See AjaxChannel class for more information about this. >> >> To be able to do what you want I suggest to use IResource to upload >> to. This way there wont be lock on the server side and with >> AjaxChannels with different names at the client side you will solve >> both problems. >> >> On Mon, Jan 16, 2012 at 2:51 AM, malebu <milton.quranda@> wrote: >>> I have a requirement where i have to upload a video from a page and show >>> the >>> upload progress when the upload is 100% complete need to update the >>> progress >>> label as processing video. >>> >>> I decided to go with a simple outer <div> and internal <div> while update >>> the internal <div> percentage to show the progress. Finally i added a >>> Label >>> inside the internal <div> to show the status... >>> >>> /<div style="border: 1px solid #5d4617; padding: 3px; background-color: >>> #191B10;" > >>> <div style="width:400px; background-color: #555555; color: >>> white; font-size: 8px;" align="left"> >>> <div style="width:0%; background-color: #FF9900;" >>> align="right" wicket:id="customProgress">Loading...</div> >>> </div> >>> </div>/ >>> >>> >>> Finally i added AjaxSelfUpdatingTimerBehavior to the internal <div> to >>> fetch >>> the progress and label every 2 seconds. >>> >>> When i click on submit button.. the label is not update while the form is >>> being submitted. it shows the final progress i.e. 100% and processing >>> completed after file is uploaded. >>> >>> I am using AjaxButton to upload on Ajax. >>> >>> Any idea how i can achieve this? >>> >>> -- >>> View this message in context: >>> http://apache-wicket.1842946.n4.nabble.com/Label-not-updating-on-AJaxButton-submit-tp4298302p4298302.html >>> Sent from the Users forum mailing list archive at Nabble.com. >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >> >> >> >> -- >> Martin Grigorov >> jWeekend >> Training, Consulting, Development >> http://jWeekend.com >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Label-not-updating-on-AJaxButton-submit-tp4298302p4302580.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
