Ok so I have the following page/form element that allows a user to enter a search string to locate a project. Possible matches appear in a list below the search field. The goal is to let users click the relevant search result and then have the controller perform some action in relation to the record associated with the clicked result:

<apex:page standardController="Opportunity" extensions="ProjectLookupController"  

        <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
            <apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">

            <!-- SEARCH TAB -->
            <apex:tab label="Associate" name="tab1" id="tabOne">

            <apex:actionRegion >  
            <apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
            <apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/>
            <apex:inputText id="txtSearch" value="{!searchString}" />
              <span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span>

          <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
            <apex:pageBlock id="searchResults"> 
              <apex:pageBlockTable value="{!results}" var="p" id="tblResults">
                <apex:column >
                  <apex:facet name="header">
                    <apex:outputPanel >Project (Click to Associate)</apex:outputPanel>
                    <apex:outputlabel value="{!p.Name}" rendered="{!NOT(ISNULL(p.Id))}">
                        <apex:actionSupport event="onclick" action="{!associateProject}" >
                            <apex:param name="associatedProject" value="{!p.Id}"/> 

I have the following controller code that attempts to read the value for parameter associatedProject from the page:

    public PageReference associateProject() {

    String project = ApexPages.currentPage().getParameters().get('associatedProject');

    system.debug('Current page :' + ApexPages.currentPage().Id);

    system.debug('Project to associate to:' + project);

    return null;

Unfortunately, the associatedProject parameter that I'm pulling in from my page is coming in a null. Any pointers?

3 Answers 3


The parameter you are sending is not called 'associateProject' but 'associatedProduct'.

You just have to do:

String project = ApexPages.currentPage().getParameters().get('associatedProduct');
  • My bad. I had already corrected this in my code but still getting a null value being passed to the controller. I've updated the original post with correction.
    – vshake
    Feb 2, 2017 at 18:18

Try adding the assignTo attribute on your <apex:param>. This will allow you to assign the value you're trying to access to a variable in your controller.

In Visualforce:

<apex:actionSupport event="onclick" action="{!associateProject}" >
    <apex:param name="associatedProject" value="{!p.Id}" assignTo="{!projectId}"/> 

Add this to your apex controller:

public Id projectId {get; set;}

And your method would be:

public PageReference associateProject() {

    system.debug('Current page :' + ApexPages.currentPage().Id);

    system.debug('Project to associate to:' + projectId);

    //Your code to process it

    return null;

Unfortunately the above suggestions didn't quite work but did point me in the right direction. I ended up using a commandLink and things came together.

In VF:

<apex:commandLink value="{!p.name}" action="{!associateProject}"> 
    <apex:param name="associatedProject" value="{!p.Id}"/> 

In controller:

public PageReference associateProject() {

    Id associatedProjectId = ApexPages.currentPage().getParameters().get('associatedProject');

    System.debug('Project to associate to: ' +   associatedProjectId);      

    return null;

You must log in to answer this question.

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