0

I have created a visualforce page that displays a list of contacts associated with an opportunity. This is displayed in a section on the opportunity page layout. I need to open the contact record in a new tab.

<apex:page standardController="Opportunity" 
extensions="OpportunityApprenticeDetails_CX" tabStyle="Contact">
<apex:form >
<apex:pageBlock >
    <apex:pageBlockTable value="{!listContacts}" var="conts">

        <apex:column headerValue="First Name">
            <apex:commandLink value="{!conts.firstname}" target="_blank">
            <apex:param name="param1" value="{!conts.id}" assignTo="
            {!contact.id}"/>
            </apex:commandLink>
        </apex:column>
        <apex:column headerValue="LastName">
            <apex:outputField value="{!conts.lastname}"/>
        </apex:column>
        <apex:column value="{!conts.email}"/>
        <apex:column headerValue="Account Name">
            <apex:outputLink value="/{!conts.accountid}">
            {!conts.account.name}</apex:outputLink>
        </apex:column>


    </apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page> 
0

2 Answers 2

1

You can use like this way using apex:outputLink and in the value attribute specify URLFOR with the action and Id.

<apex:outputLink value="{!URLFOR($Action.Contact.View, conts.id)}" target="_blank">
        {!conts.firstname}
 </apex:outputLink>

Refer my blog post Different ways of navigation

1

You can use the target= attribute on your <apex:outputLink> components to control how links are opened. Using target="_blank" will result in opening a new window or tab.

In this instance, you may be having difficulty because you're using an <apex:commandLink> instead of an <apex:outputLink>. What you're doing is not firing a controller action method, so you don't need a command link and a parameter. You can populate the URL of your output link component using the URLFOR() formula function, or simply construct it with a forward slash as you do already in the Account link lower in your page. (I like to use URLFOR() because it protects against implementation details, although that one seems unlikely to change).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .