You need to sign in to do that
Don't have an account?

Creating Custom VF Page and displaying an existing Object
Hello all.
I am working on a "phase 2" requirement where I am going to be creating a custom VF page with information from the SFDC_Proejcts__c object.
A little background. When the user is on the Projects tab and they want to add a resource (person) to be assigned to the project, they click the "add resource" button and it brings you to a different page where you enter in the information. Works great.
However, the powers that be would like all of this to happen on one page. So when they go to the new Projects page, they can add the reference (person) to the project without being redirected to a different page.
So the question is, can you have a VF page that contains your custom information that also displays in-page another page?
Thanks
--Todd Kruse
Certainly. Your page code:
<apex:page standardController="SFDC_Projects_c" controllerExtensions="ResourceToo">
<!-- your code for the portion of the page that displays Projects, use "proj" to refer
to the project object -->
<!-- below is just an example field -->
<apex:inputField value="{!resource.name}" />
<!-- more stuff like that -->
</apex:page>
And your controller extension:
public class ResourceToo {
private final SFDC_Projects__c proj;
private final SFDC_Resources__c resource;
public ResourceToo(ApexPages.StandardController.stdController) {
this.project = (SFDC_Projects__c) stdController.getRecord();
// you probably actually want to do a test here,
// so you only create a resource when one
// doesn't already exist; otherwise you want to get an
//existing resource
this.resource = new SFDC_Projects__c(project=proj);
}
//You need getters for the fields too
public PageReference save() {
//you really want the following 2 lines in a
//try-catch for DML exceptions
update project;
insert resource; //should really probably be an upsert in case
//resource isn't new.
return //whatever page reference you want to return
}
}
Hope this helps,
Avrom