You need to sign in to do that
Don't have an account?
Raghu Sharma 6
VF Page in Edit and Create Mode
I need to create a VF Page for Account for creating, viewing and editing records. What is the best approach to handle the fields for opening them for edit and view only mode? Can we use the same VF page to handle all the scenarios? How to code controller logic to handle multiple scnearios(save, edit and view)?
For new and Edit check record Id from parameter and based on the parameter you can render the page section.
1. Use standaerController and extension controller for use standard salesforce functionality,
2. Use dynamic Visualforce page for render the Edit (New and Edit Record) and detail page section.
a. If we were to use two VF pages, are you suggesting to use salesforce input fields for edit and create on VF page and use salesforce output field for viewing the records on VF page?
b. As you suggest to rerender the page, why do we need to use two pages?
Please find the below code:
Visualforce Page:
Controller:
Also tested the code as below:
If you pass the value Mode=Edit while calling the VF Page:
If we don't pass the Mode while calling the VF Page:
Please do let me know if it helps you.
Regards,
Mahesh
You can use single page.
To maintain the code and segregate two different actions, I was suggesting 2 page. In salesforce you achive multiple solution for single problem.
~Thanks,
Onkar Kumar
How to redirect to standard page once the record is saved? what should be the approach to clone the record?
As we are using the Standard Controller with Extension and we are not overriding the Save method, it will automatically redirect to Standard Page which is a defect behaviour of Save method.
Please do let me know if it helps you.
Regards,
Mahesh