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

disabling command link

Hello guys,


Need some help with the Command Link. I know there's no attribute as "Disable" for <apex:commandLink >, like we do have for <apex:commandButton> . But as per the requirement, i want to have the link disabled for a particular profile. Can this be achived??


All your replies are highly appreciated.




Rahul SharmaRahul Sharma

Dont have any idea for disabling <apex:commandLink>

Have you tried using <apex:outputlink>, it has disable attribute and works also same as commandLink.


I wouldn't waist too much time with that. Go around it using something like this:



if you would like to have something like 


<apex:commandlink action="{!yourControllerMethod}"  value="texttoclick" disable="{!yourBooleanVariable}"/>


use this


<apex:commandlink action="{!yourControllerMethod}"  value="texttoclick" rendered="{!yourBooleanVariable}"/>

<apex:outputtextvalue="texttoclick" rendered="{!not(yourBooleanVariable)}"


so the <apex:outputtext component would simulate the commandlink disabled


Hope it helps


khillan bhardwajkhillan bhardwaj

There is not direct direct attribute in command link you can diable to command link by using either javascript or Css.
For example i have done it by using :
       a.disabled {
           pointer-events: none;
           cursor: default;
 <Apex:commandLink styleclass="disabled" value="Go to Google" onclick="alert('hello');" id="khillan"/>
this script disable it whenever page is loaded. if you want to disable when you want then you need help of javascript or jquery.
for example :

when you want disable use statement :
var kk = document.getElementById('elelment id');

when you want to enable then use javascript statements :
var kk = document.getElementById('elelment id');

Hope it will help you.

Khillan Singh
Vladimir Romanov #1Vladimir Romanov #1

Following Krishna Sambaraju's advice, I made my commandLink look like this:
<apex:commandLink value="pushMe" action="{!myFunc}" onclick="if(!myOnclckHandler()){return false;}" />

Muthuraj TMuthuraj T
You can implement like this. 
      <apex:commandButton action="{!save}" disabled="{!IF(HasAccess, false, true)}" value="Save" />