Need some help with the Command Link. I know there's no attribute as "Disable" for , like we do have for . But as per the requirement, i want to have the link disabled for a particular page. Can this be achived?? my code- how i will use commandLink ?


You can do this with JavaScript:

<apex:commandLink onclick="return {!not disableLink};" ...

Where disableLink is a Boolean value, either as a function: public Boolean getDisableLink() { ... }, or as public Boolean disableLink { get; set; }). When an onclick function returns false, the default action (e.g. activating the link) is not performed.

You can also do this by way of not doing anything in your action method:

public PageReference doSomeAction() {
    if(actionDisabled) {
        return null;
    // Do whatever you're going to do here

This has the disadvantage of taking a round trip to the server, of course.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.