views:

463

answers:

1
A: 

I found a workaround for this problem. Seems I have to use s:link together with a normal a href tag. Only having href tag doesn't work for some reason.

<s:link action="#{fileHandler.downloadById()}" value="#{file.name}" propagation="none">
    <f:param name="fileId" value="#{file.id}"/>
</s:link>
<a href="#{servletPath.path}?fileId=#{file.id}&amp;actionMethod=#{path.replace('/','')}%2Fstatus%2Fstatus_pdf.xhtml%3AfileHandler.downloadById()&amp;">
    download
</a>

The servletPath.path returns the servlet path ie http://mydomain.com/download.seam You can decide to put login-required=true on the download.seam if you want users to login before downloading a file.

@Observer("org.jboss.seam.security.loginSuccessful")
public void servletPath() {
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    this.path = request.getRequestURL().toString().replace("login.seam", "download.seam");
}
Shervin