You need to sign in to do that
Don't have an account?
Patrick Conner
Linked Results on Custom VisualForce Page
Hey!
I'm having some trouble displaying linked results on a VisualForce page; I don't seem to have the best grasp on the outputlink function. What I'd like is for results to be displayed as below, but for the Name to link to the individual contact. Any idea how I can do this? Please let me know if you need more info, and thanks for the help!
Here's what I have for the pageBlockTable:
<apex:pageBlockTable value="{!contacts}" var="contact">
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Name" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Name" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputLink value="/!{Contact.id}">{!Contact.Name}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Email" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Email" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!contact.Email}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Phone" action="{!toggleSort}" rerender="results,debug">
<apex:param name="Phone" value="Phone.name" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!contact.Phone}"/>
</apex:column>
</apex:pageBlockTable>
I'm having some trouble displaying linked results on a VisualForce page; I don't seem to have the best grasp on the outputlink function. What I'd like is for results to be displayed as below, but for the Name to link to the individual contact. Any idea how I can do this? Please let me know if you need more info, and thanks for the help!
Here's what I have for the pageBlockTable:
<apex:pageBlockTable value="{!contacts}" var="contact">
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Name" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Name" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputLink value="/!{Contact.id}">{!Contact.Name}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Email" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Email" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!contact.Email}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Phone" action="{!toggleSort}" rerender="results,debug">
<apex:param name="Phone" value="Phone.name" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!contact.Phone}"/>
</apex:column>
</apex:pageBlockTable>
Chang this line:
To:
(Note how I swapped the exclamation mark on the curly brace around)
Another way you could do this would be using the URLFOR, which is in my opinion safer to use:
Here are a couple links on URLFOR and other Visualforce functions:
https://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_functions.htm
http://salesforcesource.blogspot.com/2008/12/urlfor-function-finally-explained.html
All Answers
Chang this line:
To:
(Note how I swapped the exclamation mark on the curly brace around)
Another way you could do this would be using the URLFOR, which is in my opinion safer to use:
Here are a couple links on URLFOR and other Visualforce functions:
https://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_functions.htm
http://salesforcesource.blogspot.com/2008/12/urlfor-function-finally-explained.html
<apex:outputLink value="/{!Contact.id}">{!Contact.Name}</apex:outputLink>