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
shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com 

Is it possible to execute a method of controller on click on apex:outputlink????

Hi,

    I am writing a search query that returns results in a list format. Name of entry is a type of output link that redirects user to detail page of that entry, when clicked upon. Now there is one field called Flag__c (default value==' false') . On first time click of this output link I want to toggle the value from false to True and next time onwards I want to keep it as it is ( i.e value should change only once , next time onwards change should not happen).

       How can this be done? Shall I continue to use apex:outputlink or shall I switch to apex:commandlink?

Big VBig V

I woold suggest you to use command link. But if your requirement is such that you should use only outputlink, here is the solution to call a method in the controller.

 

<apex:outputlink value="mention URL here if neccesary" onclick="method1()" > linkname </apex:outputlink>

<apex:actionFunction action="{!method}" name="method1"/>

 

 

 

 

here "method" in action  attribute is the method in your controller.

 

If this has solved your question mark it as solved or else let me know.

 

regards,

Big V