Skip to main content
Hello,

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 pages...page 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]);

contactstoadd.remove(rowIndex);

return page3;

}

​}

 
16 answers
  1. Jun 25, 2015, 7:19 PM

    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}"/>

    </apex:repeat>

0/9000