You need to sign in to do that
Don't have an account?
sbrmath
Conditional display of link
Is it possible to display link based on certain condition on the page itself?
Here is what i want to to
If (condition) {
<apex:outputLink value="/{!result.account.Id}" target="_parent"> {!result.account.FirstName + ' ' + result.account.LastName} </apex:outputLink>
} else {
<apex:outputtext value="{!result.account.FirstName + ' ' + result.account.LastName}"/>
}
condition is based on value in another variable on the page.
What is the exact syntax for if on the visualforce page?
Hi sbrmath;
You meant something like this?
<apex:page>
<apex:variable value="showSecond" var="myVar" />
<apex:outputlink rendered="{!myVar=='showFirst'}" >I am FIRST link</apex:outputlink>
<br/>
<apex:outputlink rendered="{!myVar=='showSecond'}" >I am SECOND link</apex:outputlink>
<apex:page>
All Answers
If this is an output page, then you use this syntax.
{!IF(opportunity.IsPrivate, "Private", "Not Private")}
Or, if you have a custom controller or extension, you can create a property, like this:
public String myLink { get { if (condition) { return blah; } return other_blah; } }
If this is an edit page, and you want to rerender the link dynamically as the user inputs something, then you'll need actionSupport and rerender.
Hi sbrmath;
You meant something like this?
<apex:page>
<apex:variable value="showSecond" var="myVar" />
<apex:outputlink rendered="{!myVar=='showFirst'}" >I am FIRST link</apex:outputlink>
<br/>
<apex:outputlink rendered="{!myVar=='showSecond'}" >I am SECOND link</apex:outputlink>
<apex:page>