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;
}
}
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>