function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Problem getting a parameter in Visualforce, always null

I'm trying to pull in the ID of a row... unfortunately, despite setting an <apex:param> for it, when I query the variable I assigned it to I always get "null" back.

<apex:page controller="cntrl_ext_save" sidebar="false" >
<apex:sectionHeader title="Professional Development Products" />

 <apex:form >
 <apex:selectList size="1" required="true" value="{!selectedProd}">
<apex:selectoptions value="{!items}"/>
<apex:commandButton action="{!add}" value="New Dev. Product" />
 <apex:pageBlock title="Items">
   <apex:pageBlockButtons >
     <apex:commandButton value="Save"  action="{!save}"  rerender="rows" status="outStatus"/>
     <apex:commandButton value="Reset" action="{!reset}" rerender="rows" status="outStatus" 
      immediate="true" />
     <apex:actionStatus startText="(.................Processing.................)" stopText="" id="outStatus" onstop="Reset"/>
   <apex:pageBlockTable border="1" cellpadding="6" value="{!components}" var="a" id="rows" >
      <apex:column headerValue="Delete"><apex:commandButton value='Del' action='{!remove}' onclick="return confirm('Are you sure—');"><apex:param value="{a.Id}" assignTo="{!dParam}" /></apex:commandButton></apex:column>
      <apex:column headerValue="Product">"{!a.PricebookEntry.Name}"</apex:column>
      <apex:column headerValue="Quantity"><apex:inputField value="{!a.Quantity}" /></apex:column>     
      <apex:column headerValue="Sales Price"><apex:inputField value="{!a.UnitPrice}" /></apex:column>
      <apex:column headerValue="List Price">"{!a.ListPrice}"</apex:column>
      <apex:column headerValue="Total Price">"{!a.TotalPrice}"</apex:column>

public class cntrl_ext_save {
        public String selectedProd {get;set;}
        public String dParam;
        public String getdParam() {
            return dParam;
        public void setdParam(String s) {
            dParam = s;
        public List<OpportunityLineItem> componentList;  // list of components to appear in the multi-line.
        public PageReference reset() {
            componentList = [select id, quantity, totalprice, unitprice, listprice,, pricebookentry.product2.Family from OpportunityLineItem where OpportunityId = :ApexPages.currentPage().getParameters().get('id') and pricebookentry.product2.Family = '03 Professional Services'];
            return null;
        public List<OpportunityLineItem> getComponents() {
            if(componentList == null) reset(); 
            return componentList;
        public void setComponents(List<OpportunityLineItem> Components) {
            componentList = Components;
        public PageReference save() {
            upsert componentList;
            return null;    
        public PageReference add() {
            Opportunity pb = [select Pricebook2Id from Opportunity where Id = :ApexPages.currentPage().getParameters().get('id')];
            PricebookEntry prod = [select UnitPrice, Name, Id from PricebookEntry where Product2Id = :selectedProd and Pricebook2Id = :pb.Pricebook2Id];
            componentList.add(New OpportunityLineItem(OpportunityId = ApexPages.currentPage().getParameters().get('id'), UnitPrice=prod.UnitPrice, PricebookEntryId=prod.Id, Quantity=1));
            return null;                
        public PageReference remove() {
            system.debug('test '+dParam);
            OpportunityLineItem oli = Database.query('select Id from OpportunityLineItem where id='+dParam);
            delete oli;
            return null;
        public List<SelectOption> getItems() {
            List<SelectOption> op = new List<SelectOption>();
            for(Product2 prod : [select id, name from Product2 where family='03 Professional Services']) op.add(new SelectOption(prod.Id, prod.Name));
            return op;


For anyone who has this problem, I was able to solve it. Apparently there's a bug with the commandButton

I changed it to a commandLink and my code worked just fine.