You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ch...@t-systems.com on 2014/04/22 10:42:35 UTC
AjaxDownload setResponsePage
Hello,
Iam using AJAXDownload to download some data which will created on the fly, while clicking an AjaxButton. Moreover Iam using an AbstractResourceStream. In its getInputStream method, I get an byte array. This method can throw some exception, which I will catch. If an exception is thrown, I want to redirect to an errorpage. It is shown in the code below. Nothing happens when the exception is thrown. Can somebody help me please?
download = new AJAXDownload() {
@Override
protected IResourceStream getResourceStream() {
return new AbstractResourceStream() {
InputStream data;
@Override
public InputStream getInputStream(){
try {
data = new ByteArrayInputStream(ConsoleDataHandlerImpl.getInstance().getReportAsByteStream(slaReportModel.getTxtDatumVon(),slaReportModel.getTxtDatumBis()));
} catch (Exception e) {
log.error(ExceptionUtils.getStackTrace(e));
setResponsePage(new InternalError(e.getMessage()));
}
return data;
}
@Override
public void close() throws IOException {
data.close();
}
};
}
@Override
protected String getFileName(){
return filename;
}
};
this.add(download);
download.initiate(target);
Mit freundlichen Grüßen
Christoph Manig
Systems Engineer
T-Systems International GmbH
Systems Integration - SC Travel, Transport & Logistics
Hoyerswerdaer Str. 18
01099 Dresden
tel.: +49 (0) 351 / 8152 - 188
fax: +49 (0) 351 / 8152 - 209
email: Christoph.Manig@t-systems.com
T-SYSTEMS INTERNATIONAL GMBH
Aufsichtsrat: Thomas Dannenfeldt (Vorsitzender)
Geschäftsführung: Reinhard Clemens (Vorsitzender), Dr. Ferri Abolhassan, Thilo Kusch, Dr. Markus Müller, Georg Pepping, Hagen Rickmann
Handelsregister: Amtsgericht Frankfurt am Main HRB 55933
Sitz der Gesellschaft: Frankfurt am Main
WEEE-Reg.-Nr. DE50335567
Re: AjaxDownload setResponsePage
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
It is OK.
You can also do: throw new RestartResponseException(...)
Martin Grigorov
Wicket Training and Consulting
On Tue, Apr 22, 2014 at 11:51 AM, <Ch...@t-systems.com> wrote:
> I resolved it with this line:
>
> getRequestCycle().replaceAllRequestHandlers(new
> RenderPageRequestHandler(new PageProvider(new
> InternalError(e.getMessage()))));
>
> is this a good way?
>
>
> Mit freundlichen Grüßen
> Christoph Manig
>
> -----Ursprüngliche Nachricht-----
> Von: Manig, Christoph
> Gesendet: Dienstag, 22. April 2014 10:43
> An: users@wicket.apache.org
> Betreff: AjaxDownload setResponsePage
>
> Hello,
>
> Iam using AJAXDownload to download some data which will created on the
> fly, while clicking an AjaxButton. Moreover Iam using an
> AbstractResourceStream. In its getInputStream method, I get an byte array.
> This method can throw some exception, which I will catch. If an exception
> is thrown, I want to redirect to an errorpage. It is shown in the code
> below. Nothing happens when the exception is thrown. Can somebody help me
> please?
>
> download = new AJAXDownload() {
> @Override
> protected IResourceStream getResourceStream() {
> return new AbstractResourceStream() {
> InputStream data;
> @Override
> public InputStream getInputStream(){
> try {
> data = new
> ByteArrayInputStream(ConsoleDataHandlerImpl.getInstance().getReportAsByteStream(slaReportModel.getTxtDatumVon(),slaReportModel.getTxtDatumBis()));
> } catch (Exception e) {
> log.error(ExceptionUtils.getStackTrace(e));
> setResponsePage(new
> InternalError(e.getMessage()));
> }
> return data;
> }
>
> @Override
> public void close() throws IOException {
> data.close();
> }
> };
> }
>
> @Override
> protected String getFileName(){
> return filename;
> }
> };
> this.add(download);
> download.initiate(target);
>
>
> Mit freundlichen Grüßen
> Christoph Manig
> Systems Engineer
>
> T-Systems International GmbH
> Systems Integration - SC Travel, Transport & Logistics Hoyerswerdaer Str.
> 18
> 01099 Dresden
> tel.: +49 (0) 351 / 8152 - 188
> fax: +49 (0) 351 / 8152 - 209
> email: Christoph.Manig@t-systems.com
>
> T-SYSTEMS INTERNATIONAL GMBH
> Aufsichtsrat: Thomas Dannenfeldt (Vorsitzender)
> Geschäftsführung: Reinhard Clemens (Vorsitzender), Dr. Ferri Abolhassan,
> Thilo Kusch, Dr. Markus Müller, Georg Pepping, Hagen Rickmann
> Handelsregister: Amtsgericht Frankfurt am Main HRB 55933 Sitz der
> Gesellschaft: Frankfurt am Main WEEE-Reg.-Nr. DE50335567
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
AW: AjaxDownload setResponsePage
Posted by Ch...@t-systems.com.
I resolved it with this line:
getRequestCycle().replaceAllRequestHandlers(new RenderPageRequestHandler(new PageProvider(new InternalError(e.getMessage()))));
is this a good way?
Mit freundlichen Grüßen
Christoph Manig
-----Ursprüngliche Nachricht-----
Von: Manig, Christoph
Gesendet: Dienstag, 22. April 2014 10:43
An: users@wicket.apache.org
Betreff: AjaxDownload setResponsePage
Hello,
Iam using AJAXDownload to download some data which will created on the fly, while clicking an AjaxButton. Moreover Iam using an AbstractResourceStream. In its getInputStream method, I get an byte array. This method can throw some exception, which I will catch. If an exception is thrown, I want to redirect to an errorpage. It is shown in the code below. Nothing happens when the exception is thrown. Can somebody help me please?
download = new AJAXDownload() {
@Override
protected IResourceStream getResourceStream() {
return new AbstractResourceStream() {
InputStream data;
@Override
public InputStream getInputStream(){
try {
data = new ByteArrayInputStream(ConsoleDataHandlerImpl.getInstance().getReportAsByteStream(slaReportModel.getTxtDatumVon(),slaReportModel.getTxtDatumBis()));
} catch (Exception e) {
log.error(ExceptionUtils.getStackTrace(e));
setResponsePage(new InternalError(e.getMessage()));
}
return data;
}
@Override
public void close() throws IOException {
data.close();
}
};
}
@Override
protected String getFileName(){
return filename;
}
};
this.add(download);
download.initiate(target);
Mit freundlichen Grüßen
Christoph Manig
Systems Engineer
T-Systems International GmbH
Systems Integration - SC Travel, Transport & Logistics Hoyerswerdaer Str. 18
01099 Dresden
tel.: +49 (0) 351 / 8152 - 188
fax: +49 (0) 351 / 8152 - 209
email: Christoph.Manig@t-systems.com
T-SYSTEMS INTERNATIONAL GMBH
Aufsichtsrat: Thomas Dannenfeldt (Vorsitzender)
Geschäftsführung: Reinhard Clemens (Vorsitzender), Dr. Ferri Abolhassan, Thilo Kusch, Dr. Markus Müller, Georg Pepping, Hagen Rickmann
Handelsregister: Amtsgericht Frankfurt am Main HRB 55933 Sitz der Gesellschaft: Frankfurt am Main WEEE-Reg.-Nr. DE50335567
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org