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
Newbie999Newbie999 

Can someone explain the working of <li> and <apex:repeat> w.r.t. the below code?

<apex:page standardController="Account" recordSetVar="accounts">
    <apex:pageBlock title="Accounts">
        <apex:repeat value="{!Accounts}" var="a">
            <li>
                <apex:outputLink value="/{!a.id}">{!a.Name}</apex:outputLink>
            </li>
        </apex:repeat>
   </apex:pageBlock> 
</apex:page>

BELOW IS THE OUTPUT OF THE ABOVE PROGRAM

output of VF- standard list controller
 
Alex Bondarenko 1Alex Bondarenko 1

Hello,

apex:repeat is just like loop operator FOR and the HTML <li> tag represents a list item in ordered and unordered lists.

thus, it is the same like in Apex code

List<Account> accList  // colection of account objects
for( Account a : accList) {
    system.debug('Account Name: ' + a.Name);
}
Ajay K DubediAjay K Dubedi
Hi Newbie999,
The HTML <li> element is used to represent an item in a list. It must be contained in a parent element: an ordered list (<ol>), an unordered list (<ul>), or a menu (<menu>). In menus and unordered lists, list items are usually displayed using bullet points. In ordered lists, they are usually displayed with an ascending counter on the left, such as a number or letter.

For more details refer the below link:

https://salesforce.stackexchange.com/questions/5829/datalist-li-style

apex:repeat : 

An iteration component that allows you to output the contents of a collection according to a structure that you specify. The collection can include up to 1,000 items.

Link for apex:repeat :

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi