function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sonaperthsonaperth 

passing list of objects to visualforce page in different format.

hi guys, i need some help.

 

i need to pass a list of objects from the apex class to visualforce page.

so far, after searching around,  i can only find <apex:dataTable> and <apex:pageBlockTable> to display the objects in a table.

so for example:

 

 

public List<Contact> getContacts() {

contactObjs = [SELECT name, address, phone from Companies

where id = :System.currentPageReference().getParameters().get('id')];

return contactObjs;

}

 

 

 

then if i want to display it in a nice table i can easily use something like this:

 

 

<apex:pageBlock>

<apex:pageBlockTable value="{!Contacts}" var="con">

<apex:column value="{!con.name}" />

<apex:column value="{!con.address}" />

<apex:column value="{!con.phone}" />

</apex:pageBlockTable>

</apex:pageBlockTable>

 

 

but how if i want to display those objects like this:

 

name: qwer

address: qwer

phone: 123

 

name: asdf

address: asdf

phone 456

 

 

can anyone help me please? or tell me which documentation/pdf file should i read

thanks in advance.

aballardaballard

Take a look at<apex:repeat>

prageethprageeth

I think aballard's  answer is the best. But don't forget that,  a table can have only one column.
It means you can use a table with one column for you purpose.

<apex:pageBlock>

<apex:pageBlockTable value="{!Contacts}" var="con">

<apex:column>

name:{!con.name}<br/>

Address:{!con.address}<br/>

Phone:{!con.phone}<br/>

</apex:column>

</apex:pageBlockTable>

</apex:pageBlock> 

 
sonaperthsonaperth

you both are champions!

thanks guys, much appreciate it.