I would like to put two separate pageBlock tables that pull records from two different objects on my visualforce page. Is this possible?
Can I tuck my standard controller into the table itself somehow instead of on the "Page" level?
5 个回答
I would probably create a Custom Apex Controller with a reference to both objects and action methods to handle the two different save actions you wish to run, the main reason being that you wish to show lists of objects. Using a standard controller + extension really just confuses things since you have a bunch of functionality you won't need specific to only a small part of the data you interacting with.
So, naive code from the top of my head below:public class with sharing MyCustom Controller {
public List<CustomObj1__c> listOfCustomObjs1 {get; set;}
public List<CustomObj2__c> listOfCustomObjs2 {get; set;}
public CustomObj1__c customObj1 {get;set;}
public CustomObj2__c customObj2 {get;set;}
public MyCustomController() {
listOfCustomObjs1 = [Select id, name from CustomObjec1__c];
}
public PageReference saveCustomObj1() {
// save logic
}
}