function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
du-scodouglasdu-scodouglas 

Controller Methods

Hi,

 

I am new to the salesforce platform, and I am creating a custom visualforce page to do some work on a datatable (it is a popup from a list button forone of my custom objects) right now I am just using the standard controller for that custom object, and I am displaying some data in a dataTable, and then I have some commandButton's. Now my question is, I want to have an action performed on this data when one of the buttons is clicked, but it's sort of complex, so I figured maybe I can write a custom method for this controller? Can salesforce do this?

 

Also, how do I make a cancel button simply close the page with no changes? is there a default Action for that?

 

Loving the platform so far, just wrapping my head around it.

 

Thanks, Scott

Best Answer chosen by Admin (Salesforce Developers) 
Damien_Damien_

 


Now my question is, I want to have an action performed on this data when one of the buttons is clicked, but it's sort of complex, so I figured maybe I can write a custom method for this controller? Can salesforce do this?

 


  Yes, Salesforce can definately do this.

 

<apex:commandButton action="{!cancel}" value="Cancel" />

 

This would give you the default action for the cancel button.

All Answers

Damien_Damien_

 


Now my question is, I want to have an action performed on this data when one of the buttons is clicked, but it's sort of complex, so I figured maybe I can write a custom method for this controller? Can salesforce do this?

 


  Yes, Salesforce can definately do this.

 

<apex:commandButton action="{!cancel}" value="Cancel" />

 

This would give you the default action for the cancel button.

This was selected as the best answer
du-scodouglasdu-scodouglas

Thanks hehe, that solves the simple part.... now for the custom controller... looking for references at the moment...

 

Scott

aballardaballard

If standard controller is mostly doing what you need, then you should look into writing an extension, rather than a custom controller.  Extension allows you to add actions while still having all the standard functionality. 

du-scodouglasdu-scodouglas

Wow, I didn't even think of that, do controller classes extend just like any other Java class? can I override and overload methods if need?

aballardaballard

A controller extension is not quite like a java class extension, but you can override standard actions. 

 

I think there are good examples in the docs.