Thomas Adrian
Thomas Adrian

Reputation: 3636

Download a file using redirect in XPages only works the first time

I have an xpages containg a link which does a redirect to downloadable file

<xp:link escape="true" text="Link" id="link1">
    <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
        <xp:this.action><![CDATA[#{javascript:facesContext.getExternalContext().redirect(link to downloadable file");}]]></xp:this.action>
    </xp:eventHandler>
</xp:link>

The code works fine the first time, but the second time I click nothing happens. If I put a second link on the page with the save code that link is also not working after the first download.

is there anyway to resolve this so that I can have mulitple links?

Upvotes: 0

Views: 84

Answers (1)

Serdar Basegmez
Serdar Basegmez

Reputation: 3355

At the first click, you lose the context on the back-end. That's why it doesn't work for the second click.

Put the URL into the value attribute of the link.

Alternatively, you can post a CSJS with your SSJS code:

view.postScript("location.href='"+yourUrl+"'");

Upvotes: 2

Related Questions