Goal: I am attempting to create an 'edit' option for objects in a table, that when clicked, will take you to the appropriate object page. I'm currently trying to tie the link information to each object in the table, and when the button is clicked, it will return a PageReference object and open the appropriate page. More info: the visualforce page is being placed in the page layout of Accounts.
Problem: I'm not too sure how to set this up. This is how I have the page:
<apex:page standardController="Account" extensions="OpportunityAccountLinkController" docType="html-5.0">
<apex:form>
<apex:pageBlockTable value="{!oppHolders}" var="holder">
<apex:column>
<apex:facet name="header">Action</apex:facet>
<apex:commandButton action="{!holder.toEdit}" value="Edit"/>
</apex:column>
<apex:column value="{!holder.opp.Name}">
<apex:facet name="header">Opportunity Name</apex:facet>
</apex:column>
</apex:pageBlockTable>
<apex:form>
Im holding the info in a wrapper class, found in OpportunityAccountLinkController:
public class OppHolder {
public Opportunity opp {get;set;}
public PageReference editUrl {get;set;}
public OppHolder(Opportunity o, PageReference pr) {
this.opp = o;
this.editUrl = pr;
}
public PageReference toEdit() {
return this.editUrl;
}
}
And this is how pageReferences are formed in that controller:
PageReference pr = new PageReference(opp.Id + '/e?retURL=' + opp.AccountID);
This question may be a bit open ended, but how do I open this link, in a new page? Right now, everything else displays correctly, except for the link. It opens within the injected visualforce page, and it takes me to an incorrect page. It gives an error on that page: "Formula Expression is required on the action attributes", which confuses me as I thought I called the method correctly.
Thanks