+ Start a Discussion
Tyler Harris 8Tyler Harris 8 

Pass clicked link to Apex variable?

Hello all,

I have a link that I want passed to a String Variable in the Controller onclick. I'm failing at accomplishing this. Any help would be useful.

<apex:form >
    <apex:actionRegion >
    <apex:actionFunction name="setLink" action="{!makeLink}" reRender="link">
        <apex:param name="param1" assignTo="{!setLink}" value="" />
<a id="downloadContent" href="{!$Site.Prefix}/sfc/servlet.shepherd/version/download/{!con.Id}" onclick="setLink()"><i class="fa fa-download"></i></a>

public String linkClick{
    public PageReference makeLink(){
        return null;

Best Answer chosen by Tyler Harris 8
You need to add get set for setLink in your controller and replace anchor tag with this
<a id="downloadContent" href="{!$Site.Prefix}/sfc/servlet.shepherd/version/download/{!con.Id}"onclick="setLink(this.href)"><i class="fa fa-download"></i></a>