0

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;
    }

}
1
  • Yes with help of apex:outputLink
    – NITHESH K
    Sep 12, 2017 at 12:15

2 Answers 2

2

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;
    }    
}
5
  • Is it not possible through <a> tag..And also through outputlink its not working Nitesh Sep 12, 2017 at 12:27
  • Your page also get redirect ?
    – NITHESH K
    Sep 12, 2017 at 12:32
  • Yes it is redirecting but value is not populating Sep 12, 2017 at 12:33
  • @DeepakAgarwal Updated answer for you
    – NITHESH K
    Sep 12, 2017 at 12:56
  • @DeepakAgarwal Your welcome......
    – NITHESH K
    Sep 13, 2017 at 4:24
1

The <apex:actionsupport> tag only works inside Visualforce tags, not directly on standard HTML tags. As shown in another answer, you can use <apex:commandLink> to create a link that directly calls a controller method, without needing actionsupport. You can use <apex:outputlink> in VF to create an <a> in the rendered HTML that links to an URL (as opposed to an action).

You can also use <apex:actionfunction> to create a javascript function that invokes a controller method, and call that JS function from anywhere that you would normally call a JS function in a page.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .