public class UploadRequestTarget implements IRequestTarget {

....


 public void detach(RequestCycle requestCycle) {}


 @SuppressWarnings({ "static-access", "unchecked" })

public void respond(RequestCycle requestCycle) {

HttpServletRequest
request=((WebRequest)requestCycle.getRequest()).getHttpServletRequest();

HttpServletResponse
response=((WebResponse)requestCycle.getResponse()).getHttpServletResponse();


          response.setHeader("Connection","close");



        FileItemFactory factory = new DiskFileItemFactory();

        ServletFileUpload upload = new ServletFileUpload(factory);


        List items=null;

        PrintWriter out=null;

try {

out = response.getWriter();

items = upload.parseRequest(request);

         for (int i = 0; i < items.size(); i++) {

        DiskFileItem item = (DiskFileItem) items.get(i);

            // As we are interested not in regular form fields, we filter
only files

            if (!item.isFormField()) {

            String FileName=.......

            item.write(new File(fileName));

                out.print("RESP.100");

                out.flush();

            }

        }

// deberia crear el album

} catch (FileUploadException e1) {

out.print("RESP.200");

        // flush the stream to speed up applet notification

        out.flush();

e1.printStackTrace();

} catch (Exception e) {

e.printStackTrace();

}

 }


}


On Thu, Sep 3, 2009 at 8:11 AM, FaRHaN <farhan.ba...@ymail.com> wrote:

> Sorry, i want to say how can i use this example to fulfill my uploading
> requirements ?
>
> As there is only one class (ReceiverServlet.java) for uploading in
> PickWick. I already knows its functionality but my question is that, Apache
> Commons FileUpload requires HttpServletRequest for parsing Request
> (servletFileUpload.parseRequest(httpServletRequest)). I don't have any
> experience of using Servlets in Wicket tha's why i want to know, How can we
> set or get HttpServletRequest in a wicket application, like in doGet() &
> doPost() in Servlets ?
>
> Also, IMultipartWebRequest is required for uploading in Wicket. How can i
> cast it to HttpServletRequest, as an Exception occur while casting
> IMultipartWebRequest to HttpServletRequest.
>
> Thanks...
>
>
>
>
>
> ________________________________
> From: FaRHaN <farhan.ba...@ymail.com>
> To: users@wicket.apache.org
> Sent: Thursday, September 3, 2009 1:16:19 PM
> Subject: Re: How to use Apache Commons FileUpload in Wicket ?
>
> How can i view PickWick Examples (with Code), from Pickwick-Wicket Stuff
> WIKI site?
>
>
>
>
>
> ________________________________
> From: Fernando Wermus <fernando.wer...@gmail.com>
> To: users@wicket.apache.org
> Sent: Wednesday, September 2, 2009 6:44:14 PM
> Subject: Re: How to use Apache Commons FileUpload in Wicket ?
>
> You have pickwick project that has an example exaclty as the way you want
>
> On Wed, Sep 2, 2009 at 4:02 AM, FaRHaN <farhan.ba...@ymail.com> wrote:
>
> > I want to upload a file using apache commons FileUpload API. As it
> requires
> > HttpServletRequest for uploading files, but in wicket
> > IMultipartWebRequest/IMultipartServletWebRequest is required for
> uploading
> > purposes.
> >
> > How can I use apache commons FileUpload for uploading in Wicket ? Is
> there
> > any example to do so ?
> >
> > Thanks...
> >
> >
> >
> >
>
>
>
>
> --
> Fernando Wermus.
>
> www.linkedin.com/in/fernandowermus
>
>
>
>



-- 
Fernando Wermus.

www.linkedin.com/in/fernandowermus

Reply via email to