Generally, when one talks about lookups, one already has an existing sObject in mind. Suppose we have an sObject called My_Object__c
with two lookups:
- A lookup to Account called
Account__c
- A lookup to the Another_Object__c
Another_Object__c
Let's write a simple VF Page that allows a user to populate both lookups. But first, let's write a simple controller:
public class TwoInputController {
public My_Object__c myObject {get;set;} // the My_Object__c record we're interested in working with
public TwoInputController(){ // the Constructor for this Class
this.myObject = new My_Object__c(); // create a new My_Object__c record to play with
// note myObject hasn't ever been inserted
}
}
Now, let's write a simple VF Page that has the two desired lookups:
<apex:page controller="TwoInputController">
<apex:form>
<apex:pageBlock title="Check out the Lookups" columns="1">
<apex:inputField value="{!myObject.Account__c}"/>
<apex:inputField value="{!myObject.Another_Object__c}"
</apex:pageBlock>
</apex:form>
</apex:page>