Lets see how to use onclick on the <apex:outputText> Tag.
Its very simple, but it took 3 hours to find the solution for it.
Here you go,
Its just a simple code on Account Object.
VF Page
<apex:page standardController="Account" extensions="outputfielddblclick_extn" id="pg1">
<apex:form id="frm1" >
<apex:pageBlock id="pb1">
<apex:pageBlockSection id="pbs1" >
<apex:outputpanel id="counter">
<table>
<tr>
<td> <apex:outputText value="Account Name"></apex:outputText> </td>
<td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td>
<td> <apex:outputText value="{!Account.Name}"/>
<apex:actionSupport event="ondblclick" action="{!justdisplay}" rerender="counter" status="s1"/> <!-- Status is not a mandatory -->
</td>
</tr>
</table>
</apex:outputpanel>
<apex:actionStatus id="s1"> <!-- This status is used in the actionSupport. Its not mandatory -->
<apex:facet name="start">
loading....
</apex:facet>
</apex:actionStatus>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Below is the apex class,
public class outputfielddblclick_extn {
public outputfielddblclick_extn(ApexPages.StandardController controller) {
}
public void justdisplay()
{
system.debug('RRRRRRRRInside FunctionRRRRRRRR');
// your logic here
}
}
If you double click on the Account Name, it will call the "justdisplay()" method in the class.
Below is the output screen.
It will work on apex:outputfield also.
Happy Coding!!!