You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ralf Edmund Stranzenbach <ra...@reswi.de> on 2010/03/16 20:02:54 UTC

Getting the URL for an ActionLink

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


Re: Getting the URL for an ActionLink

Posted by Ulrich Stärk <ul...@spielviel.de>.
What you have created in your getDownloadLink() method is a link to trigger a "downloadResult" event 
while you are expecting the triggering of the "action" event from the "downloadResult" component. So 
just change your event handler method's name to "onDownloadResult" and your iframe should work.

Uli

On 16.03.2010 20:02, Ralf Edmund Stranzenbach wrote:
> 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
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Getting the URL for an ActionLink

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 16 Mar 2010 16:02:54 -0300, Ralf Edmund Stranzenbach  
<ra...@reswi.de> wrote:

> Hi,

Hi!

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

Exactly the way you're doing it. But I guess your use of an iframe isn't  
correct. Why don't you try the automation using JavaScript instead?

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org