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"
title="Search"
showHeader="false"
sideBar="false"
tabStyle="Account"
id="searchpg">
<apex:form>
<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>
<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:facet>
<apex:outputlabel value="{!p.Name}" rendered="{!NOT(ISNULL(p.Id))}">
<apex:actionSupport event="onclick" action="{!associateProject}" >
<apex:param name="associatedProject" value="{!p.Id}"/>
</apex:actionSupport>
</apex:outputlabel>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:actionRegion>
</apex:tab>
</apex:tabPanel>
</apex:outputPanel>
</apex:form>
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?