You need to sign in to do that
Don't have an account?
Apex PageReference getParameters not accepting parameter
I have the following extension class. From the debug I know that the id is valid. But I don't get the record. Help!
public class ProjDetailExtension {
Public List<Quote__c> quote {Get;Set;}
Public ProjDetailExtension(Apexpages.StandardController ctrl){
If(apexpages.currentPage().getParameters().containsKey('id')){
quote = new List<Quote__c>();
String myID = apexpages.currentPage().getParameters().get('id');
Quote = [Select Name, System__c, Coverage_Area__c, System_Price__c, Project__c From
Quote__c Where Project__c = : myID ];
}
}
Public pageReference GetQuote(){
ID id;
id = apexPages.currentPage().getParameters().get('qID');
System.debug('The ID is ' +id);
pageReference ref = Page.QuoteDetail;
ref.getParameters().get(id);
ref.setRedirect(True);
return ref;
}
markup
<apex:page standardController="Project__c" extensions="ProjDetailExtension" >
<apex:form >
<apex:pageBlock title="Project Record " id="proj">
<apex:pageblocksection columns="2">
<apex:outputField value="{!Project__c.Account__c}"/>
<apex:outputField value="{!Project__c.Contact__c}"/>
<apex:outputField value="{!Project__c.Name}"/>
<apex:outputField value="{!Project__c.Description__c}"/>
<apex:outputField value="{!Project__c.City__c}"/>
<apex:outputField value="{!Project__c.Date__c}"/>
<apex:outputField value="{!Project__c.Status__c}"/>
<apex:outputField value="{!Project__c.State__c}"/>
<apex:outputField value="{!Project__c.Zip__c}"/>
<apex:outputField value="{!Project__c.Country__c}"/>
<apex:outputField value="{!Project__c.Requested_By__c}"/>
<apex:outputField value="{!Project__c.Effective_Date__c}"/>
<apex:outputField value="{!Project__c.End_Date__c}"/>
<apex:outputField value="{!Project__c.Created_By__c}"/>
<apex:outputField value="{!Project__c.Project_Total__c}"/>
</apex:pageblocksection>
<apex:pageBlockSection columns="1">
<b>This is the Quote Section</b>
<apex:pageBlockTable value="{!Quote}" var="q" >
<apex:column >
<apex:commandLink value="{!q.name}" action="{!GetQuote}" >
<apex:param name="qID" value="{!q.id}" />
</apex:commandLink>
</apex:column>
<apex:column value="{!q.System__c}" />
<apex:column value="{!q.Coverage_Area__c}" />
<apex:column value="{!q.System_Price__c}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Back" action="{!List}" />
<apex:commandButton value="Edit" action="{!Edit}" />
<apex:commandButton value="New Quote" action="{!NewQuote}" />
<apex:commandButton value="Cancel" action="{!Cancel}" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Please try the below changes in your code:
Create the new varaible:
Public Id qID {get;set;}
Change the below line in vfpage:
<apex:param name="qID" value="{!!q.id}" assignTo="{!qID}"/>
ref.getParameters().get(id);
Change this method:
Public pageReference GetQuote(){
// ID id;
// id = apexPages.currentPage().getParameters().get('qID');
// System.debug('The ID is ' +id);
PageReference redirectPage = Page.QuoteDetail;
redirectPage.setRedirect(true);
redirectPage.getParameters().put('id',qID );
return redirectPage;
}
In the QuoteDetail visualforce page controller you have to use the below line;
Id id= System.currentPageReference().getParameters().get('id');
Can you please Let me know if it works or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Raj
Please chosse the best answer which one helps to you!!! that provide the great achievement to my help!!!
Refer the below screenshot for how to mark the best answer!!!
Thanks,
Raj