You need to sign in to do that
Don't have an account?
sush
public List<Lead> getMyLeads() {
String LeadId = ApexPages.currentPage().getParameters().get('t.Id');
How to pass Id from a command link to Controller
Hi,
I'm displaying a table of records in a visualforce page (retrieved through a list from Custom Controller).I'm having a command link (Accept) for each record and when I click this link few updations should happen to that record and it should be displayed.But how to pass the Id parameter to the action method(AcceptLead) in Controller to update that particular record.
My visual force code is as follows:
<apex:page Controller="CustomController2">
<apex:form >
<apex:pageblock Title="test">
<apex:pageblock Title="test">
<apex:pageBlockTable value="{!myLeads}" var="t" id="LeadInbox">
<apex:column >
<apex:facet name="header"><b>Action</b></apex:facet>
<apex:commandLink action="{!acceptLead}" value="Accept" >
</apex:commandLink>
</apex:column>
<apex:column value="{!t.id}"/>
<apex:column value="{!t.name}"/>
</apex:pageBlockTable>
<apex:commandLink action="{!acceptLead}" value="Accept" >
</apex:commandLink>
</apex:column>
<apex:column value="{!t.id}"/>
<apex:column value="{!t.name}"/>
</apex:pageBlockTable>
</apex:pageblock>
</apex:form>
<apex:pageBlock id="test"></apex:pageBlock>
</apex:page>
<apex:pageBlock id="test"></apex:pageBlock>
</apex:page>
Controller Class:
public class CustomController2 {
public List<Lead> getMyLeads() {
String CurrentUserId = UserInfo.getUserId();
List<Lead> myVar = [select id, name from Lead where OwnerId =: CurrentUserId AND Status != 'xxxAccepted' And isConverted = False limit 10];
return myVar;
}
List<Lead> myVar = [select id, name from Lead where OwnerId =: CurrentUserId AND Status != 'xxxAccepted' And isConverted = False limit 10];
return myVar;
}
public PageReference acceptLead() {
String LeadId = ApexPages.currentPage().getParameters().get('t.Id');
}
}
Its very urgent.Any pointer would be appreciated.
Thanks
In that command link just pass the parameter like this
<apex:commandlink>
<apex:param name="abc" value="objectname.id">
</apex:commandlink>
and get the value in the controller like this
Id id1 = System.currentPageReference().getParameters().get("abc");
HI Sush,
you can use <apex:param> tag with <apex:commandLink> tag
<apex:param name="paramName" value="paramValue"/>