You need to sign in to do that
Don't have an account?
SF Operator
Show multiple objects on visualforce
I want to know how can I show more than 1 object without getting an error.
This is my actual code:
Class:
this.AccountList = [Select Owner.name
From Account
this.target = this.AccountList.get(0);
Page:
<apex:pageBlockSection title="" collapsible="false" columns="2" rendered="{!target.Name != ''}">
<apex:outputText value="{!target.Name}"/>
</apex:pageBlockSection>
Page:
<apex:pageBlockSection title="" collapsible="false" columns="2">
<apex:pageBlockTable value="{!target}" var="a">
<apex:column value="{!a.Name}"/>
</apex:pageBlockTable></apex:pageBlockSection>
Class:
this.target = [Select Owner.name
From Account Where Name != ''];//With target being a List<Account>
If it helps please mark as correct so it can help others.
All Answers
Greetings!
If you want to combine two different objects in a single table and display in a visual force page then use Wrapper class to combine two objects and display in your visual force page. Check this sample post to get start
1. https://www.interactiveties.com/blog/2012/visualforce-wrapper-class.php
2. http://bobbuzzard.blogspot.co.uk/2010/09/rotating-visualforce-table.html
3. https://developer.salesforce.com/page/Wrapper_Class
Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Sorry,it is still not clear.
You mean,you would like to display one item each from the 2 or more Objects.
If those objects are related to each other or have the common relationship with one Object then please refer this (https://developer.salesforce.com/forums/?id=906F000000093S3IAI).
If they are not related to each other then you can refer this (https://developer.salesforce.com/forums/?id=9060G000000Xdo1QAC) for sample code.
Thank you!
Page:
<apex:pageBlockSection title="" collapsible="false" columns="2">
<apex:pageBlockTable value="{!target}" var="a">
<apex:column value="{!a.Name}"/>
</apex:pageBlockTable></apex:pageBlockSection>
Class:
this.target = [Select Owner.name
From Account Where Name != ''];//With target being a List<Account>
If it helps please mark as correct so it can help others.