You need to sign in to do that
Don't have an account?
kriiyer
Kindly advise on what I'm missing here.
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:
Code:
<apex:dataTable id="dataTableObj" value="{!allTermDates}" var="a" title="Details of Effective Date" rendered="{!showADJTable}"> <apex:column> <apex:commandButton value="Remove" action="{!removeTermDates}" onclick="return confirmDeletion();"> <apex:param name="termDates" value="{!a.Id}"></apex:param> </apex:commandButton> </apex:column> <apex:column> <apex:outputField value="{!a.Date__c}"/> </apex:column> </apex:dataTable>
Code:
<script language="Javascript"> function confirmDeletion(){ return confirm('The Terms Date will be permanently deleted. Do you wish to continue—'); } </script>
My Controller method looks something like this:
Code:
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]; if(termDat.Date_Type__c.equals('Payment')){ termPayDateCancelMap.remove(termDat.Id); }else if(termDat.Date_Type__c.equals('Adjustment')){ termDateCancelMap.remove(termDat.id); }else if(termDat.Date_Type__c.equals('Cash Out')){ termDateCashCancelMap.remove(termDat.Id); } delete termDat; return null; }
Kindly advise on what I'm missing here.
Thanks in advance.
Krishnan
You should update your param tag to include the assign to attribute:
Then update your controller with this:
This will set the value of the termId to the value specified in the param component.
Alexis
Message Edited by gargamel on 10-17-2008 04:53 AM
Message Edited by gargamel on 10-17-2008 04:54 AM
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 ?
Thanks
Arun
Message Edited by Arun Bala on 11-14-2008 12:13 PM