Saturday, July 26, 2014

Repeater Usage in Visualforce Page.

Repeater Usage in Visualforce Page.

In this post i am giving an example of how to use <apex:repeat> tag in Visualforce page.

Controller Class: 

Public class TableController{
 public List<Account> accList{get;set;}

 Public TableController(){
  accList= new List<Account>();
  accList= [select id,name,type,industry from Account];

Visualforce Page Class:

<apex:page controller="TableController" showheader="true" sidebar="false">
 <apex:form >
   <table border="1" width="650Px">
      <th> Account Name</th>
      <th> Type  </th>
      <th> Industry</th>
    <apex:repeat value="{!accList}" var="a">
        <td> {!a.Name} </td>
        <td> {!a.type} </td>
        <td> {!a.industry} </td>


Test Class:

Public class PagblockTable_Test {
 static testmethod void testPageblockTable(){
  //Test converage for the myPage visualforce page
  PageReference pageref = Page.RepeatorExample;
  // create an instance of the controller
  TableController tc= new TableController();

out put :

save image

If we observe the output of VF page while using <apex:repeat> tag there is no default salesforce styles applied. suppose if you use pageBlock table then salesforce default styles will apply. if you want to apply your custom styles for table and columns you can apply with <apex:repeat> tag.


Post a Comment

| ,