Clicking on a button and moving to a new page with questions:
public PageReference runTest () {
insert newSession;
PageReference ref = new PageReference ('/apex/LaunchTests');
return ref;
}
Controller:
public class LaunchTestsController {
public List <Test_item__c> newItem { get; set;}
public LaunchTestsController () {
string str = 'SELECT Id, Question__c, Response__c, Response1__c, Responce2__c, Answer__c FROM Test_item__c';
this.newItem = Database.query(str);
}
}
VF Page:
<apex:page controller="LaunchTestsController" >
<apex:form >
<apex:pageBlock title="Questions">
<apex:pageBlockTable value="{!newItem}" var="item">
<apex:column value="{!item.Question__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
See the following blog, I think this is what you are looking for. Basically you will have to user apex:ActionSupport on your input lookup field to fetch the information of Selected lookup record.See examplehttp://bobbuzzard.blogspot.com/2011/11/retrieve-related-object-fields.html