Discussion:
AbstractResource not writing PDF resource to IE
Celia Xu
2013-01-31 16:23:13 UTC
Permalink
I have TabbedPanels contain lazyloadpanels imbedded in a panel.
In IE it doesn't show any data in the popup window whereas in firefox it
prompts error: "*Last cause: ResourceResponse#setWriteCallback() must be
set.*" in the first tab and works fine in other tabs.
here is snippet:

ResourceLink<Void> pdfLink = new ResourceLink<Void>("pdfLink", new
AbstractResource(){
@Override
protected ResourceResponse newResourceResponse(Attributes attributes)
{
ResourceResponse r = new ResourceResponse();
try {
final byte[] pdfBytes = getPDF();

r.setFileName(DynamicFileName+".pdf");
r.setContentType("application/pdf");
r.setContentDisposition(ContentDisposition.INLINE);
r.setContentLength(pdfBytes.length);
* r.setWriteCallback*(new WriteCallback(){
@Override
public void writeData(Attributes attributes)
{
attributes.getResponse().write(pdfBytes);
}
});
r.disableCaching();
} catch (Exception e) {
e.printStackTrace();}
return r; } });
PopupSettings popupSettings = new PopupSettings(FILENAME,
PopupSettings.RESIZABLE
| PopupSettings.SCROLLBARS).setHeight(500).setWidth(700);
pdfLink.setPopupSettings(popupSettings);

I'm also generating Excel file and using exact same structure as pdf one but
works as expect.
Anyone knows why?
Thanks



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AbstractResource-not-writing-PDF-resource-to-IE-tp4655978.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Martin Grigorov
2013-01-31 16:33:07 UTC
Permalink
Hi,

I guess because of :

} catch (Exception e) {
e.printStackTrace();}
return r; } });

i.e. you may return incomplete resourceResponse.
check your logs
Post by Celia Xu
I have TabbedPanels contain lazyloadpanels imbedded in a panel.
In IE it doesn't show any data in the popup window whereas in firefox it
prompts error: "*Last cause: ResourceResponse#setWriteCallback() must be
set.*" in the first tab and works fine in other tabs.
ResourceLink<Void> pdfLink = new ResourceLink<Void>("pdfLink", new
AbstractResource(){
@Override
protected ResourceResponse
newResourceResponse(Attributes attributes)
{
ResourceResponse r = new ResourceResponse();
try {
final byte[] pdfBytes = getPDF();
r.setFileName(DynamicFileName+".pdf");
r.setContentType("application/pdf");
r.setContentDisposition(ContentDisposition.INLINE);
r.setContentLength(pdfBytes.length);
* r.setWriteCallback*(new WriteCallback(){
@Override
public void writeData(Attributes attributes)
{
attributes.getResponse().write(pdfBytes);
}
});
r.disableCaching();
} catch (Exception e) {
e.printStackTrace();}
return r; } });
PopupSettings popupSettings = new PopupSettings(FILENAME,
PopupSettings.RESIZABLE
|
PopupSettings.SCROLLBARS).setHeight(500).setWidth(700);
pdfLink.setPopupSettings(popupSettings);
I'm also generating Excel file and using exact same structure as pdf one but
works as expect.
Anyone knows why?
Thanks
--
http://apache-wicket.1842946.n4.nabble.com/AbstractResource-not-writing-PDF-resource-to-IE-tp4655978.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>
Celia Xu
2013-01-31 16:54:58 UTC
Permalink
Thanks for reply.
I changed r.setContentDisposition(ContentDisposition.*INLINE*);
to r.setContentDisposition(ContentDisposition.*ATTACHMENT*);

Then in firefox it can open/download the file properly but IE prompt cannot
download from server.
any suggestion?
error:
<Loading Image...>
Thanks



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AbstractResource-not-writing-PDF-resource-to-IE-tp4655978p4655982.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Celia Xu
2013-01-31 18:33:59 UTC
Permalink
So finally I made it work just by moving byte array resource outside the
newResourceResponse method....




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AbstractResource-not-writing-PDF-resource-to-IE-tp4655978p4655984.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org

Loading...