You need to sign in to do that
Don't have an account?
Edwards71
Visualforce custom extension controller problem
Hi,
I'm getting an "Incompatible types since an instance of SObject is never an instance of Contract" when trying to create a very simple visualforce page.
Page uses standard contract conroller plus extension which will be used to populate some of the contract fields 'behind the scenes' which the user wont see on the visual force page. The visualforce page will be dealing with new records only.
Any ideas what's going on here? I'm stumped and it must be something simple!
Thanks in advance
Extension controller: public class myContract { public myContract(ApexPages.StandardController controller) { Contract con = (Contract) controller.getRecord(); } Visualforce page: <apex:page standardController="Contract" extensions="myContract"> <apex:form > <apex:pageBlock title="Historic Contract" mode="edit"> Use this form to input details of an Historic contract that does not need implementation.<p/> Historic Contracts are needed to support active Virtual contract terms <p/> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save" rerender="all"/> <apex:commandButton action="{!Cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Contract Details" columns="2"> <apex:inputfield value="{!contract.ContractNumber}" /> <p/> <apex:inputfield value="{!contract.accountid}" /><p/> <apex:inputfield value="{!contract.name}" required="true" style="width:350px"/> <apex:inputfield value="{!contract.StartDate}" required="true"/> <apex:inputfield value="{!contract.ContractTerm}" required="true"/> <apex:inputfield value="{!contract.EndDate}" required="true"/> </apex:pageblocksection> </apex:pageBlock> </apex:form> </apex:page>
Thanks for this. I'll use this code for something else as its a bit neater than what I had.
It turns out that I had a rogue Apex class which I thought had been deleted which duplicate methods hence my problem. All works fine now that I have deleted it.
It's always the simple things!
All Answers
Hi Edwards,
You can try this way , simply you can achive
Thanks for this. I'll use this code for something else as its a bit neater than what I had.
It turns out that I had a rogue Apex class which I thought had been deleted which duplicate methods hence my problem. All works fine now that I have deleted it.
It's always the simple things!