I have a VF page that allows child records to be updated , this is working well.EXCEPT for the following page I am trying to use ParentId=ApexPages.currentPage().getParameters().get('ParentId'); and Pagereference page=new pagereference('/'+parentId);
I can enter test data in successfully but the follow up page after clicking save throws URL No Longer Exists
This is the VF page
<apex:page controller="AddingChildController" >
<apex:form >
<apex:variable var="rowNum" value="{!0}" />
<apex:pageBlock >
<apex:variable var="rowNum" value="{!0}" />
<apex:PageBlockTable value="{!childList}" var="int">
<apex:facet name="footer">
<apex:commandLink value="Add" action="{!insertRow}"/>
</apex:facet>
<apex:column headerValue="Lead Generator">
<apex:inputField value="{!int.Lead_Gen__c}"/>
</apex:column>
<apex:column headerValue="Pay Run">
<apex:inputField value="{!int.Pay_Run__c}"/>
</apex:column>
<apex:column headerValue="Monday">
<apex:inputField value="{!int.Monday__c}"/>
</apex:column>
<apex:column headerValue="Tuesday">
<apex:inputField value="{!int.Tuesday__c}"/>
</apex:column>
<apex:column headerValue="Wednesday">
<apex:inputField value="{!int.Wednesday__c}"/>
</apex:column>
<apex:column headerValue="Thursday">
<apex:inputField value="{!int.Thursday__c}"/>
</apex:column>
<apex:column headerValue="Friday">
<apex:inputField value="{!int.Friday__c}"/>
</apex:column>
<apex:column headerValue="Delete">
<apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
<apex:param value="{!rowNum}" name="index"/>
</apex:commandLink>
<apex:variable var="rowNum" value="{!rowNum+1}"/>
</apex:column>
</apex:PageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!insertChild}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
And this is the controller
public class AddingChildController {
Id parentId;
public List<Time_Sheets__c> childList {get;set;}
public Integer rowNum{get;set;}
public AddingChildController(){
Id childId = ApexPages.currentPage().getParameters().get('childId');
childList = new List<Time_Sheets__c>();
childList.add(new Time_Sheets__c());
ParentId=ApexPages.currentPage().getParameters().get('ParentId');
}
public pagereference insertChild(){
insert childList;
Pagereference page=new pagereference('/'+parentId);
Return page;
}
public void insertRow(){
childList.add(new Time_Sheets__c());
}
public void delRow(){
rowNum =
Integer.valueof(apexpages.currentpage().getparameters().get('index'));
childList.remove(rowNum);
}
}
any ideas where I am going wrong ?
parentId=xyz
in the query string when you're navigating to (or testing) this page/controller?