You have iterated over a list before in Tutorial #5: Using Standard User Interface Components. The <apex:pageBlockTable> component you used produced output that conforms to the standard platform look and feel. Visualforce has a mirror suite of components that allow you to iterate without producing anything other than standard HTML—letting you customize it as you wish.
- Add the following to your accountDisplayVisualforce page:
<apex:dataTable value="{!account.contacts}" var="item"> <apex:column value="{!item.name}"/> <apex:column value="{!item.phone}"/> </apex:dataTable>
- You can also produce a standard HTML unordered list instead of a table by using the <apex:dataList> component. Try this:
<apex:dataList value="{!account.contacts}" var="item"> <apex:outputText value="{!item.name}"/> </apex:dataList>
- If you’d like absolute control, use the <apex:repeat> component that simply iterates. You have to do all the outputting yourself. For example, you can mimic the output of the<apex:dataList> component as follows:
<ul> <apex:repeat value="{!account.contacts}" var="item"> <li><apex:outputText value="{!item.name}"/></li> </apex:repeat> </ul>
No comments:
Post a Comment