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

apex:param parameter value does not reach the controller

Hello all,
We currently have a requirement of displaying the contract term dates in a table with links to delete them. It looks something like this.
Contract Term Dates                         Action
02/02/2009                                           Remove
09/03/2009                                           Remove
where Remove is a link which would delete the contract term date record and refresh the page. I used the apex:commandLink for implementing the Remove link functionality. It does delete the record. However, it throws a Javascript error which says Invalid Argument. The error comes from the javascript snippet generated by the Salesforce engine on the page.
I further tried changing the commandLink to commandButton. I use the apex:param to pass the contract term date ID to the controller. However, for some reason the ID does not reach the controller and the controller method throws a List does not return any rows for assignment error.
Here is what I wrote:
<apex:dataTable id="dataTableObj" value="{!allTermDates}" var="a"  title="Details of Effective Date" rendered="{!showADJTable}">
        <apex:commandButton value="Remove" action="{!removeTermDates}" onclick="return confirmDeletion();">
            <apex:param name="termDates" value="{!a.Id}"></apex:param>
        <apex:outputField value="{!a.Date__c}"/>


<script language="Javascript">
 function confirmDeletion(){
   return confirm('The Terms Date will be permanently deleted. Do you wish to continue—');

 My Controller method looks something like this:

public PageReference removeTermDates(){
 Id termId= System.currentPageReference().getParameters().get('termDates');
 System.assertNotEquals(null, termId);
 Term_Dates__c termDat = [select Id, Date_Type__c from Term_Dates__c where id=:termId];



 }else if(termDat.Date_Type__c.equals('Adjustment')){

 }else if(termDat.Date_Type__c.equals('Cash Out')){


 delete termDat;
 return null;

Kindly advise on what I'm missing here.
Thanks in advance.

You should update your param tag to include the assign to attribute:
<apex:param name="termDates" value="{!a.Id}" assignto="termId"/>

Then update your controller with this:
private String termId;
public String getTermId() { return this.termId; }
public void setTermId(String el) { this.termId = el; }

Remove This ===>
Id termId= System.currentPageReference().getParameters().get('termDates');

This will set the value of the termId to the value specified in the param component.


Message Edited by gargamel on 10-17-2008 04:53 AM

Message Edited by gargamel on 10-17-2008 04:54 AM
Arun BalaArun Bala
Hi folks,
I have a similar requirement but I don't want to refresh the entire page after removing a record. I basically would like to do this at the client side without involving the controller class.

Is that possible ? Any hints folks ?


Message Edited by Arun Bala on 11-14-2008 12:13 PM