You need to sign in to do that
Don't have an account?
Commandlink parameter pass problem
External entry point
Line Item Edit Page <apex:page standardController="In__c" showHeader="true" extensions="InnovationExtension" tabStyle="In__c"> <apex:sectionHeader title="Commercialization/Timing Items Edit" subtitle="{!InnovationToolItem.Name}"></apex:sectionHeader> <apex:form > <apex:pageBlock title="Edit" mode="Edit"> <apex:pagemessages /> <apex:pageBlockButtons > <apex:commandButton action="{!checkListItemSave}" value="Save" /> <apex:commandButton action="{!checkListItemCancel}" value="Cancel" /> </apex:pageBlockButtons> <apex:pageBlockSection title="General Information" columns="1"> <apex:outputField value="{!InnovationToolItem.Name}" style="width: 325px; height: 18px"/> <apex:inputField value="{!InnovationToolItem.Needed_or_Not__c}" /> <apex:inputField value="{!InnovationToolItem.Owner__c}" style="width: 200px; height: 18px"/> <apex:inputField value="{!InnovationToolItem.Target_Completion_Date__c}" style="width: 200px; height: 18px"/> <apex:inputField value="{!InnovationToolItem.Actual_Completion_Date__c}" style="width: 200px; height: 20px"/> <apex:inputField value="{!InnovationToolItem.Status__c}" style="width: 300px; height: 18px"/> <apex:inputField value="{!InnovationToolItem.Comments__c}" style="width: 600px; height: 72px"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <apex:relatedList subject="{!InnovationToolItem}" list="NotesAndAttachments" /> </apex:page>
"
master details - list view page:
<apex:page standardController="In__c" showHeader="true" extensions="InnovationExtension" tabStyle="In__c">
..........
<apex:pageBlock title="Commercialization Checklist" mode="view"> <!-- Display General Group --> <apex:pageBlockSection title="General" id="Generals" columns="1"> <apex:pageBlockTable value="{!Generals}" var="ge"> <apex:column value="{!ge.No__c}" width="50" /> <apex:column headervalue="Items" width="500"> <apex:commandLink action="{!checkListItem}" value="{!ge.Name}" > <apex:param name="Checklist" value="{!ge.id}"/> </apex:commandLink> </apex:column> <apex:column headerValue="Needed?" width="50" > <apex:outputField value="{!ge.Needed_or_Not__c}" /> </apex:column> <apex:column headerValue="Exist?" width="50" > <apex:outputField value="{!ge.Exist_or_Not__c}" /> </apex:column> <apex:column headerValue="Owner" width="150" > <apex:outputField value="{!ge.Owner__c}" /> </apex:column> <apex:column headerValue="Original Target Completion Date" width="150" > <apex:outputField value="{!ge.Target_Completion_Date__c}" /> </apex:column> <apex:column headerValue="Forecast/Actual Completion Date" width="150" > <apex:outputField value="{!ge.Actual_Completion_Date__c}" /> </apex:column> <apex:column headerValue="Status" width="150" > <apex:outputField value="{!ge.Status__c}" /> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection>
standard controller extension public class InnovationExtension { private final In__C Innovations; List<Innovation_Tool__c> Launchs; Innovation_Tool__c InnovationToolItem; public Innovation_Tool__c getInnovationToolItem(){
//Error here, when I click the save button in line item page, the system give the the error displayed above. Innovation_Tool__c InnovationToolItem = [Select Id, IsDeleted, Name, No__c, Innovation__c, Needed_or_Not__c, Exist_or_Not__c, Group__c, Owner__c, Target_Completion_Date__c, Actual_Completion_Date__c, Status__c, Comments__c FROM Innovation_Tool__c where Id = :ApexPages.currentPage().getParameters().get('Checklist')]; return InnovationToolItem; } public InnovationExtension(ApexPages.StandardController controller) { this.Innovations = (In__C)controller.getRecord(); InnovationsList = [Select Id, IsDeleted, Name, Market_Drivers_Trends__c FROM In__c where Id = :ApexPages.currentPage().getParameters().get('id') Limit 1]; Launchs = (List<Innovation_Tool__c>)[Select Id, IsDeleted, Name, No__c, Innovation__c, Needed_or_Not__c, Exist_or_Not__c, Group__c, Owner__c, Target_Completion_Date__c, Actual_Completion_Date__c, Status__c FROM Innovation_Tool__c where Innovation__c = :ApexPages.currentPage().getParameters().get('id') and Group__c='Launch' order by No__c]; } public PageReference checkListItem() { PageReference pdfPage = Page.ADPItemEdit; pdfpage.setRedirect(false); return pdfPage; } public PageReference checkListItemSave() { update InnovationToolItem; return Page.Innovation; } public PageReference checkListItemCancel() { return Page.Innovation; } }
I used same standard controller extension in both pages, as per the tips from Visualforce Page developer wazird guide line, the controll should not be rerender when I switched in different page but use same controller, not sure where wrong, Please save me!!!
Thanks a lot
That exception means that your query didn't return any results. And since the page loads fine initially, I suspect that your parameter is null. The reason this is happening is because when you hit save, you're doing a postback that first calls your getters, then your setters, and you query param is wiped out once you hit save -- you're no longer passing in the checklist parameter that you need. To illustrate the issue, I suspect that this would fix it:
<apex:commandButton action="{!checkListItemSave}" value="Save"> <apex:param name="Checklist" value="{!$CurrentPage.parameters.Checklist}"/> </apex:commandButton>
Although this is not the solution I would suggest to you, I think it illustrates the issue. We do not automatically forward your parameters for you, it wouldn't make sense to.
The real problem here is that you have no reason to be doing that query more than once. Especially considering that you have several calls to InnovationToolItem in your page, it's going to call the getter for every expression that references it, and thus will run the query every time. That's overkill. What you should be doing is storing off the object once you load it the first time:
public Innovation_Tool__c getInnovationToolItem(){
if (InnovationToolItem == null) { InnovationToolItem = [Select Id, IsDeleted, Name, No__c, Innovation__c, Needed_or_Not__c, Exist_or_Not__c, Group__c, Owner__c,
Target_Completion_Date__c, Actual_Completion_Date__c, Status__c, Comments__c FROM Innovation_Tool__c
where Id = :ApexPages.currentPage().getParameters().get('Checklist')];
}
return InnovationToolItem;
}
All Answers
That exception means that your query didn't return any results. And since the page loads fine initially, I suspect that your parameter is null. The reason this is happening is because when you hit save, you're doing a postback that first calls your getters, then your setters, and you query param is wiped out once you hit save -- you're no longer passing in the checklist parameter that you need. To illustrate the issue, I suspect that this would fix it:
<apex:commandButton action="{!checkListItemSave}" value="Save"> <apex:param name="Checklist" value="{!$CurrentPage.parameters.Checklist}"/> </apex:commandButton>
Although this is not the solution I would suggest to you, I think it illustrates the issue. We do not automatically forward your parameters for you, it wouldn't make sense to.
The real problem here is that you have no reason to be doing that query more than once. Especially considering that you have several calls to InnovationToolItem in your page, it's going to call the getter for every expression that references it, and thus will run the query every time. That's overkill. What you should be doing is storing off the object once you load it the first time:
public Innovation_Tool__c getInnovationToolItem(){
if (InnovationToolItem == null) { InnovationToolItem = [Select Id, IsDeleted, Name, No__c, Innovation__c, Needed_or_Not__c, Exist_or_Not__c, Group__c, Owner__c,
Target_Completion_Date__c, Actual_Completion_Date__c, Status__c, Comments__c FROM Innovation_Tool__c
where Id = :ApexPages.currentPage().getParameters().get('Checklist')];
}
return InnovationToolItem;
}
Hi,
I do have same kind of issue. When I use commandLink in following :
<apex:variable var="forecastIndex" value="{!0}"/>
<apex:commandLink value="{!greaterThanSymbol}" action="{!copySalesQuantityToNext}">
<apex:param name="forecastIndex" value="{!forecastIndex}"/>
</apex:commandLink>
I can get value in 'forecastIndex' parameter from the controller, but when I use commandButton I can't.
<apex:variable var="forecastIndex" value="{!0}"/>
<apex:commandButton value="{!greaterThanSymbol}" action="{!copySalesQuantityToNext}">
<apex:param name="forecastIndex" value="{!forecastIndex}"/>
</apex:commandButton>
What can be the issue?
Thanks,
Kuldeep
Cheers,
www.sfdcfanboy.com