1

VisualForce Page:

<apex:page standardController="Account" extensions="InlineEditingHelper">
  <apex:form>
    <apex:pageBlock title= "outputcomponents">
        <apex:outputPanel id="editfield">
            <apex:outputlabel value="Account Name (Double Click To Edit)   :  " for="Accname">
                <apex:actionSupport event="ondblclick" action="{!inlineEdit}" rerender="editfield"/>
            </apex:outputlabel>         
            <apex:outputText label="" value="{!Account.Name}" rendered="{!NOT(editmode)}" id="Accname"/>
            <apex:inputText label="" value="{!Account.Name}" rendered="{!editmode}" id="Accname2"/> 
        </apex:outputPanel>      
    </apex:pageBlock >
  </apex:form>
</apex:page>

Controller Extension

public with sharing class InlineEditingHelper {
    public boolean editmode {get;set;}
    public InlineEditingHelper(ApexPages.StandardController controller) {
        editmode = false;
    }
    public void inlineEdit() {
        system.debug('entered here');
        editmode = true;
    }
}

I got this code but not able to implement it on my reference

5
  • Are you facing any problem in your implementation or in understanding how it works? In case of your implementation, please paste you code, what you want and where you are stuck. Mar 2, 2016 at 7:11
  • why don't you use salesforce standard functionality.. <apex:outputField with inlineEditsupport developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/…
    – Ratan Paul
    Mar 2, 2016 at 7:19
  • 1
    I will not use outputfield because i have to show property and apex outputfield worked on with sobject field ex. Integer count{get;set;} show with outputtext and on dblclick show inputtext field thanks for your rply
    – ArjunSFDC
    Mar 2, 2016 at 7:27
  • @ArjunSFDC then you need to go with rerender solution.. Or javascript to show/ hide fields..
    – Ratan Paul
    Mar 2, 2016 at 7:29
  • @Ratan yes Javascript code will help me did you have any example ??
    – ArjunSFDC
    Mar 2, 2016 at 7:39

2 Answers 2

0

Efficient way to use actionsupport

Documentation:

public class InlineEditingHelper {

public String strName {get;set;}
public Boolean isEditable {get; private set;}

public InlineEditingHelper ()
{
 strName  = 'Test 1';
 isEditable = true;
}

public void changeEditable(){
  isEditable = isEditable ? false:true;
}
}

VF page

<apex:page Controller="InlineEditingHelper">
    <apex:form id="frm">
        <apex:pageBlock  id="pblock">

            <apex:pageBlockSection id="pbsection">
                <apex:outputpanel id="counter">
                   <apex:outputText value="{!strName }" rendered="{!isEditable }"/>
                   <apex:actionSupport event="ondblclick" action="{!changeEditable}"
                      rerender="frm" />
                </apex:outputpanel> 
                <apex:InputText value="{!strName }" rendered="{!!isEditable }">
                <apex:actionSupport event="ondblclick" action="{!changeEditable}"
                      rerender="frm" />
                </apex:InputText >
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
1
  • @ArjunSFDC glad it helped..
    – Ratan Paul
    Mar 2, 2016 at 10:05
0

try this way

<apex:page standardController="Account" extensions="InlineEditingHelper">
  <apex:form>
     <script>
          function dblClick(){
              inEdit();
          }
      </script> 
    <apex:actionFunction name="inEdit" action="{!inlineEdit}" rerender="editfield" />  
    <apex:pageBlock title= "outputcomponents">
        <apex:outputPanel id="editfield">
            <apex:outputlabel value="Account Name (Double Click To Edit)   :  " />
            <apex:outputPanel id="editfieldIn" ondblclick="dblClick();" >
                <apex:outputText label="" value="test" id="Accname" rendered="{!NOT(editmode)}"/>
            </apex:outputPanel>
            <apex:inputText label="" value="{!Account.Name}" id="Accname2" rendered="{!editmode}"/> 
        </apex:outputPanel>  

    </apex:pageBlock >
  </apex:form>
</apex:page>
2
  • ex. Integer count{get;set;} show with outputtext and on dblclick show inputtext field
    – ArjunSFDC
    Mar 2, 2016 at 7:29
  • just replace outputtext with outputField and remove the lable
    – apKash
    Mar 2, 2016 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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