Java Mailing List Archive

http://www.gg3721.com/

Home » users.tapestry »

Getting the URL for an ActionLink

Ralf Edmund Stranzenbach

2010-03-16

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi,

in one of my applications i use an ActionLink to provide a download link for an Excel file. I simply put something like this into my .tml file:

<t:actionlink t:id="DownloadResult" t:context="analysisEntityId" href="#">Download</t:actionlink>

This action leads to a method in the page class that implements the Excel download:

public XLSAttachment onActionFromDownloadResult(Long id) {
if (id != null) {
AnalysisEntity analyis = analysisDao.findByAnalysisId(id);
if (analyis != null) {
String filename = excel.prepareResultSheet(analyis);
InputStream stream = new FileInputStream(filename);

return new XLSAttachment(stream, analyis.getTopic()
.getName()
+ "-results", analyis.getResultfile()
.getContenttype());
}
}
}

This action link works like a charm but i tried to automate the excel download a little bit by providing an additional IFRAME element:

<iframe width="1" height="1"  src="${downloadLink}" />

public String getDownloadLink() {
Link download = resources.createEventLink("downloadResult", analysisEntityId);
return download.toString();
}

For some reason this link does not provide the same URL like the action link above:

ActionLink: ../resultpage.downloadresult?t:ac=10
download Link: ../resultpage:downloadresult?t:ac=10

The difference is the colon in the programmatically generate URL. Due to the IFRAME element, the browser tries to access this link but then Tapestry drops an exception about a missing event handler for that link.

What is the right way to provide a link to the ActionLinks action handler?

Regards,
Ralf


Attachment: smime.p7s (zipped)
©2008 gg3721.com - Jax Systems, LLC, U.S.A.