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
Lisa Kitto 7Lisa Kitto 7 

Standard List Controller TrailHead Errors

I keep getting errors related to this challenge.  It wants you to use the apex:repeat component but that does not produce an <li> HTML tag.  So I used dataList which does, but then it says that is not a apex:reat component.  SO I used both and now it says the <li> tag is not being used but when I inspect element I can see it there.  What's the deal?

<apex:page standardController="Account" recordSetVar="accounts">

        <apex:pageBlock title="Accounts">
            <apex:dataList value="{!accounts}" var="a">        
                <apex:outputLink title="Account links" value="https://na31.salesforce.com/{!a.id}">
                    <apex:outputText value="{!a.Name}"/> <br/>
                    <apex:repeat value="{!a.contacts}" var="c">
                        {!c.FirstName}
                    </apex:repeat>
                </apex:outputLink>

            </apex:dataList>
        </apex:pageBlock>

</apex:page>
Best Answer chosen by Lisa Kitto 7
Amit Chaudhary 8Amit Chaudhary 8
PLease try below code. I hope that will help you
<apex:page standardController="Account" recordSetVar="accounts">
        <apex:repeat var="a" value="{!accounts}">
            <li>
                <apex:outputLink value="/{!a.id}" >
                    {!a.name}
                </apex:outputLink>
            </li>
        </apex:repeat>

</apex:page>
Please let us know if this will help you

Thanks
Amit Chaudhary

 

All Answers

AdamDawAdamDaw
I'm not sure I follow - why not just put an <li> on {!c.FirstName} within the repeat, and skip the datalist?
Amit Chaudhary 8Amit Chaudhary 8
PLease try below code. I hope that will help you
<apex:page standardController="Account" recordSetVar="accounts">
        <apex:repeat var="a" value="{!accounts}">
            <li>
                <apex:outputLink value="/{!a.id}" >
                    {!a.name}
                </apex:outputLink>
            </li>
        </apex:repeat>

</apex:page>
Please let us know if this will help you

Thanks
Amit Chaudhary

 
This was selected as the best answer
Lisa Kitto 7Lisa Kitto 7
I figured it out.  Somehoe I thought the question was saying to use a apex repeating component that was interpreted in HTML as an <li> list.

Thanks
 
Jonathan NgJonathan Ng
I had it like this and it works. Yet it evaluates it to incorrect:
<apex:outputLink id="theLink" value="{!$Site.Domain}/{!a.Id}">{!a.Name}</apex:outputLink>

Is this incorrect to implement it like this?
Lisa Kitto 7Lisa Kitto 7
I don't think you are supposed to implement it like that.  If you just put "/{!a.Id}" it will evaluate to whatever your SF url is /accountId.