+ Start a Discussion
studentstudent 

How to include a Standard Button

Hi,

 

I've made a new visualforce page for an object. As controller of this page, i made a new apex class with some additional methods...

Now I want to include the standard button "New" of this object in my own visualforce page. But everytime I include 

 

<apex:commandButton value="blabla" action="{!New}"/>

 

to my page, the error "Unknown Method 'Controller.New()' " occurs.

 

Does anybody have an idea how to include the standard button otherwise?

Thanks in advance!

 

Phil

 

Best Answer chosen by Admin (Salesforce Developers) 
prageethprageeth

Hello Student;

In order to use the standard buttons as in your page you need to have a standard controller. This is the Object type that you need to create. 

If you need to create a new Opportunity and the name of your controller is  "MyController" you can do something like below. Remember the method to create a new object is not {!new} but {!create}.

 

 

<apex:page standardController="Opportunity" extensions="MyController">

<apex:form>

<apex:commandButton value="blabla" action="{!create}"/>

</apex:form>

</apex:page> 

 

 

 

All Answers

prageethprageeth

Hello Student;

In order to use the standard buttons as in your page you need to have a standard controller. This is the Object type that you need to create. 

If you need to create a new Opportunity and the name of your controller is  "MyController" you can do something like below. Remember the method to create a new object is not {!new} but {!create}.

 

 

<apex:page standardController="Opportunity" extensions="MyController">

<apex:form>

<apex:commandButton value="blabla" action="{!create}"/>

</apex:form>

</apex:page> 

 

 

 

This was selected as the best answer
studentstudent

Hi prageeth,

 

thanks for your answer :-)