[SalesForce] apex action function on anchor tag

so here i am trying to pass the value of param to controller on click of <a> href tag.I am using <actionSupport> for that to send the value to controller with onclick event.But no value is being passed to controller.If that is not possible any alternate solutions to pass value using anchor tag.

Any suggestions

<a href="https://c.ap5.visual.force.com/apex/AgreementRegistrationPage" ><div class="fab">ENROLL</div>
        <apex:actionSupport action="{!GetName}" reRender="" event="onclick">
        <apex:param value="Health Insurance" name="PolicyName"/>
        </apex:actionSupport>
        </a>

Controller

Public class HealthInsurance {
    Public String PolicyName{get;set;}
    Public PageReference GetName(){
        system.debug('inside method');
     PolicyName=ApexPages.currentPage().getParameters().get('PolicyName');   
      system.debug(PolicyName);  
        return null;
    }

}

Best Answer

Try with this

Vf Page :

   <apex:page controller="HealthInsurance" >
    <apex:form>
        <apex:commandLink value="ENROLL"  action="{!GetName}">
        <apex:param  name="PolicyName" value="Health Insurance"/>
        </apex:commandLink >     
    </apex:form>
</apex:page>

controller

public class HealthInsurance{
 Public String PolicyName{get;set;}

    Public PageReference GetName(){
        system.debug('inside method');
        PolicyName=ApexPages.currentPage().getParameters().get('PolicyName');   
        system.debug('******** PolicyName' + PolicyName);  
        PageReference pg=new PageReference('https://c.ap5.visual.force.com/apex/AgreementRegistrationPage');
        return pg;
    }    
}
Related Topic