No I didn't use ResourceStremRequestTarget  because my aim is to  dumped
Listview component's content into excel so I used ComponentRequestTarget
which works great.

But

                WebResponse wr = (WebResponse) getResponse();
                wr.setContentType("application/vnd.ms-excel;
charset=windows-1254" );
                wr.setCharacterEncoding(Constants.ENCODING);
                wr.setHeader("content-disposition", "attachment;filename=" +
Constants.DEFAULT_EXCEL_FILE);

causes Page Expired error if click :

StatelessLink linkExcel = new StatelessLink("linkExcel") {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick() {

                getRequestCycle().setRequestTarget(
                    new ComponentRequestTarget(tableContainer) {

                        @Override
                        public void respond(RequestCycle requestCycle) {
                            Component actions =
tableContainer.get("actions");
                            actions.setVisible(false);

                            Component navigator =
tableContainer.get("navigator");
                            navigator.setVisible(false);

                            final int oldipp = listView.getRowsPerPage();

                            listView.setRowsPerPage(Integer.MAX_VALUE);
                            isExcel = true;
                            super.respond(requestCycle);

                            /* Back to original. */
                            listView.setRowsPerPage(oldipp);
                            actions.setVisible(true);
                            navigator.setVisible(true);

                        }
                    });

                WebResponse wr = (WebResponse) getResponse();
                wr.setContentType("application/vnd.ms-excel;
charset=windows-1254" );
                wr.setCharacterEncoding(Constants.ENCODING);
                wr.setHeader("content-disposition", "attachment;filename=" +
Constants.DEFAULT_EXCEL_FILE);

            }
        };

Any suggestions or samples ? .

Thanks.




2010/9/22 Rodolfo Hansen <kry...@gmail.com>

> Have you thought about using simply using a ResourceStremRequestTarget ?
>
>
> On Wed, 2010-09-22 at 20:26 +0300, Altuğ Bilgin Altıntaş wrote:
>
> > AjaxLink doesn't throw an Excel file to user.
> >
> > Also I changed the code like that :
> >
> >                  WebResponse wr =
> > (WebResponse)*target.getHeaderResponse().getResponse()
> > ;*
> >                 wr.setContentType("application/vnd.ms-excel;
> > charset=windows-1254" );
> >                 wr.setCharacterEncoding(Constants.ENCODING);
> >                 wr.setHeader("content-disposition",
> "attachment;filename=" +
> > Constants.DEFAULT_EXCEL_FILE);
> >
> > It sends the table via Ajax :) but no excel file download process begins
> >
> > Any suggestions ?
> >
> > Thanks.
> >
> >
> >
> > 2010/9/22 Rodolfo Hansen <kry...@gmail.com>
> >
> > > Use an AjaxLink (or extends abstractlink), this way the page version is
> > > not expected to increment.
> > >
> > >
> > > On Wed, 2010-09-22 at 18:27 +0300, Altuğ Bilgin Altıntaş wrote:
> > > > Hi,
> > > >
> > > > Here is code to export excel;
> > > >
> > > >  Link linkExcel = new Link("linkExcel") {
> > > >      public void onClick() {
> > > >         getRequestCycle().setRequestTarget(
> > > >                     new ComponentRequestTarget(tableContainer) {
> > > >
> > > >                         @Override
> > > >                         public void respond(RequestCycle
> requestCycle) {
> > > >                           .....
> > > >                            WebResponse wr = (WebResponse)
> getResponse();
> > > >
>  wr.setContentType("application/vnd.ms-excel;
> > > > charset=utf-8" );
> > > >
>  wr.setCharacterEncoding(Constants.ENCODING);
> > > >                            wr.setHeader("content-disposition",
> > > > "attachment;filename=" + Constants.DEFAULT_EXCEL_FILE);
> > > >                         }
> > > >
> > > >  }
> > > >
> > > > It works great.
> > > >
> > > > *Problem steps  *:
> > > >
> > > >    1. Click excel link and get the excel file - great !
> > > >    2. Click a modalwindow link (Ajax) gets "*Page Expired"* error.
> > > >
> > > >
> > > > Any suggestions on *step 2* ?
> > > >
> > > > Thanks.
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > For additional commands, e-mail: users-h...@wicket.apache.org
> > >
> > >
>
>
>

Reply via email to