Iteration Components Used In Salesforce VisualForce Pages

Iteration Components Used In Salesforce VisualForce Pages

Iteration Components Used In Salesforce Visualforce Pages

Iteration Components allow you to display the output of content on the page in the form of a list view or separated into the column-wise. By using the given components we can achieve iteration easily so here we have some examples of components that we use, Also examples here show about pagination effects on Visualforce Pages. Pagination a process to break a complete document or large no. of records into separate pages for viewing within the Salesforce, we have Next and Previous buttons or links to move either forward or backward to get a further list of elements.

<apex:pageBlockTable>

List of data that displayed as a table within either PageBlock or PageBlockSection components, which are similar to the related list or list view in a standard Salesforce page.

apexPageBlockTable
<apex:page standardcontroller="Account" recordsetvar="accounts">
    <apex:pageblock title="Account List">
        <apex:form>
            <apex:pageblocksection>
                <apex:pageblocktable value="{!accounts}" var="b" title="List Of Accounts">
                    <apex:column value="{!b.name}"></apex:column>
                </apex:pageblocktable>
            </apex:pageblocksection>
            <apex:panelgrid columns="2">
                <apex:commandlink action="{!previous}"> Previous</apex:commandlink>
                <apex:commandlink action="{!next}"> Next</apex:commandlink>
            </apex:panelgrid>
        </apex:form>
    </apex:pageblock>
</apex:page>

<apex:dataTable>

An HTML table that’s defined by iterating over a set of data, displaying information about one item of data per row.

apexDataTable
<apex:page standardcontroller="Account" recordsetvar="accounts">
    <apex:pageblock title="Account List">
        <apex:form>
            <apex:pageblocksection>
                <apex:datatable value="{!accounts}" var="a">
                    <apex:column value="{!a.name}"></apex:column>
                </apex:datatable>
            </apex:pageblocksection>
            <apex:panelgrid columns="2">
                <apex:commandlink action="{!previous}">Previous</apex:commandlink>
                <apex:commandlink action="{!next}">Next</apex:commandlink>
            </apex:panelgrid>
        </apex:form>
    </apex:pageblock>
</apex:page>

<apex:dataList>

An ordered or unordered list of values that is defined by iterating over a set of data.

apexDataList
<apex:page standardcontroller="Account" recordsetvar="accounts">
    <apex:pageblock title="Viewing Accounts">
        <apex:form id="theForm">
            <apex:pageblocksection>
                <apex:datalist var="a" value="{!accounts}" type="1">
                    {!a.name}
                </apex:datalist>
            </apex:pageblocksection>
            <apex:panelgrid columns="2">
                <apex:commandlink action="{!previous}">Previous</apex:commandlink>
                <apex:commandlink action="{!next}">Next</apex:commandlink>
            </apex:panelgrid>
        </apex:form> 
    </apex:pageblock>
</apex:page>

<apex:repeat>

An Iteration component that allows you to display the output of the contents of the collection of records according to a structure that you specify.

apexRepeat
<apex:page standardcontroller="Account" recordsetvar="accounts">
    <apex:pageblock title="Account List">
        <apex:form>
            <apex:pageblocksection>
                <apex:repeat value="{!accounts}" var="a">
                    {!a.name}
                </apex:repeat> 
            </apex:pageblocksection>
            <apex:panelgrid columns="2">
                <apex:commandlink action="{!previous}">Previous</apex:commandlink>
                <apex:commandlink action="{!next}">Next</apex:commandlink>
            </apex:panelgrid>
        </apex:form>
    </apex:pageblock> 
</apex:page>

In terms of Governor Limits, Salesforce is based on multi-tenant architecture so it has some predefined resource usage limits for every user. In general, we can display only 20 records at a time but we can exceed this range by using the controller extension.

Thanks For Reading

Happy Salesforce!!

Popular Salesforce Blogs