I have a custom VF page to create new or edit records of Type CustomObject__c
. Via a Linker__c
object such records can be related to other OtherCustomObject__c
.
To create such links I have a button on my custom new/edit page ...
<apex:page standardController="CustomObject__c" extensions="CtrlExt">
<apex:form >
...
<apex:pageBlockSection title="Linker" columns="1">
<apex:commandButton value="Link other objects" action="{!createLinks}" />
<apex:pageBlockTable value="{!linkers}" var="links">
....
...that should load another page where the user can select 0..n records of OtherCustomObject__c.
<apex:page controller="CtrlExt">
<apex:form >
<apex:pageBlockButtons >
<apex:commandButton value="Link Selected Objects" action="{!doLink}" />
<apex:commandButton value="Cancel" action="{!doCancel}" />
</apex:pageBlockButtons>
...
If he clicks Ok or Cancel he will come back to the previous page (all of his edit should be still there) and linker objects have been created from his selection.
The problem here seems to be the shared state between the custom edit page with a controller extension and the select page which is not bound to a standard controller. How can harmonize the two different page types and share viewstate between them?
public with sharing class CtrlExt {
public CtrlExt() {
}
public CtrlExt(ApexPages.StandardController stdCtrl) {
}
public PageReference doSelect() {
return Page.selectOtherObjects;
}
public PageReference doLink() {
// create Linker records
return Page.customEditNew;
}
public PageReference doCancel() {
return Page.customEditNew;
}
}