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

Command button/Re-render not working inside pageblock table


I'm trying to seek some help with the following VF page and the controller behind it, Basically, the outline of this controller is 3 1 to capture account info, page 2 to capture multiple contacts for this acct and page 3 to just show the confirmation page....and give users the option to delete the contacts one by one by with a command button.

Now, neither the OnClick action is working, nor is the method getting invoked (I'm unable to see the "inside deleteCont" message in the debug logs) and the re-rerender is not working too...Please advise on what is it I'm missing.


public class newOpportunityController {

   public Account acct {get;set;}
   public contact cont {get;set;}
   public Listcontactstoadd{get;set;}
   private static final integer maxContacts=5;
   public Integer rowIndex {get;set;}
   public pagereference page3;

public newOpportunityController() {
      if(acct == null) 
          {acct = new Account();}
      if(cont == null)
          {cont = new Contact();}
       if (contactstoadd == null) 
          {contactstoadd = new list();}
public pagereference deleteCont() {
       system.debug('inside deleteCont');
       rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
         System.debug('row to be deleted ' + rowIndex );
         System.debug('rowm to be deleted '+Contactstoadd[rowIndex]);
       return page3;

Himanshu ParasharHimanshu Parashar
can you post your vf page as well ?
Himanshu ParasharHimanshu Parashar
please take a screenshot and paste it here.
User-added image
Tried adding a screenshot...not sure if it's readable....but what's the way to paste VF code in's not letting me do it even as plain text....
Himanshu ParasharHimanshu Parashar
for rerender put pageblocktable inside a apex:outputpanel and then rerender that outputpanel it will work.

did you tried with actionfunction to call controller method ?

Thanks Himanshu....quick qstn - how can we paste the VF code here properly....Looks like there's NO way to do it now unlike APEX code and I can paste the proper code for you to see....
I don't see any code in here too....
Krishna SambarajuKrishna Sambaraju

I think the problem is with the following line of code
rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));

Are you using apex:param () or passing rowIndex through the url?

If you are using apex:param you won't be able to get the value of rowIndex using ApexPages.currentPage().getParameters().get('rowIndex').

If you can post the VF page I can help you with the solution.

Himanshu ParasharHimanshu Parashar

Hi Balaji,

It seems like there is some issue with vf page code, even I am not able to paste vf page. Recently there were spam attack on forum so perhaps SFDC has disabled it for some time. 



I actually modeled my code based on this link...but this one doesn't seem to have Outputpanel, nor the actionfunction...Also, when I looked at actionfunction example, I don't think that's what I needed....Please advise.
Hi Krishna,

I'm unable to paste the VF page here and it's a pain...Yes, I'm passing the rownumber value failing which the code wouldn't compile =)

I tried the option of using OutputPanel and putting the pageblock table inside the Output panel and it would still not work...any thoughts?
Krishna SambarajuKrishna Sambaraju

Why don't you pass the Id field in the apex:param instead of rowNumber.
<apex:commandButton value="Delete" action="{!deleteCont}" onclick="return confirm('Are you sure');">
	<apex:param name="conId" value="{!c.Id}" assignTo="{!conId}"/>
And in the controller create a public variable as below.

public string conId {get; set;}

and use this field in the deleteCont method to delete the corresponding contact.

Hi Krishna,

The issue is that this is the confirmation page before the save to db. Hence, the contacts don't have an ID yet to pass. Hence, the need to pass rownumber.
Krishna SambarajuKrishna Sambaraju
The concept of getting the rowNumber using apex:variable in a pageBlockTable doesn't seem to work. You might need to use apex:repeat like in the following example.
<apex:variable var="rowNum" value="{!0}"/>
<apex:repeat value="contacts" var="con">
       <apex:outputText value="({!rowNum}) {!con.FirstName}"/><br/>
       <apex:variable var="rowNum" value="{!rowNum + 1}"/>
Rohan SarafRohan Saraf
Hello Everyone I tried all the possible methods mentioned above and also the others but it didnt work...!!