I am trying to add a delete function in my Extension class on my visualforce page. The param on the visualforce page from the PageBlockTable row is not being passed when the CommandButton Action is being called.
VisualForce Page
<apex:pageBlockSection title="Assigned Components" columns="1">
<apex:pageBlockTable var="a" value="{!AppComponents}" >
<apex:column headerValue="Actions" width="10%">
<apex:commandButton value="edit" onclick="window.location='/apex/vfAppComponentEdit?retURL=%2F{!a.Application__c}&id={!a.id}'; return false;" />
<apex:commandButton value="delete" action="{!deleteRow}" rerender="Components"/>
<!-- **** this is where the parameter is assigned **** -->
<apex:param name="rowid" value="{!a.Id}" assignTo="{!SelectedRowId}"/>
Apex Class
public class APM_ApplicationExtension {
private final App_Components__c appComponent;
private final id appId;
/**** THIS IS THE GETTER AND SETTER WHERE THE PARAM IS SUPPOSED TO GO ***/
public string SelectedRowId{get;set;}
public APM_ApplicationExtension(apexpages.StandardController stdController){
this.appComponent = (App_Components__c)stdController.getRecord();
}
public list<App_Components__c> getAppComponents(){
list<App_Components__c> a = [select name, product__c, component_category__c, id, application__c from App_Components__c where Application__c =: appComponent.Application__c];
return a;
}
public Pagereference deleteRow(){
/*** THIS IS ALWAYS NULL ****/
system.debug('selected row id is: ' + SelectedRowId);
list<App_Components__c> appComponents = getAppComponents();
if (appComponents.size() > 0){
for(app_components__c appComponent : appComponents ){
if (appComponent.id == SelectedRowId){
delete appComponent;
system.debug('deleted');
}
}
}
return null;
}
}