I want to toggle edit mode to on/off for <apex:detail>
component for account by dynamically setting "inlineEdit
" to TRUE/FALSE attribute on click of commandbutton.
Following is my code. It keeps the detail section in editable mode only and on click of commandbutton twice, gives error:
"An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem......"
VF Page:
<apex:page standardController="Account" showHeader="true" tabStyle="account" extensions="MyExtensionClass">
<apex:pageBlock>
<style>
.activeTab {
background-color: #236FBD;
color: white;
background-image: none
}
.inactiveTab {
background-color: lightgrey;
color: black;
background-image: none
}
</style>
<apex:tabPanel switchType="client" selectedTab="tabdetails" id="AccountTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">
<apex:tab label="Details" name="AccDetails" id="tabdetails">
<apex:detail relatedList="false" title="true" inlineEdit="{!setEdit}" id="detailPageID" />
</apex:tab>
</apex:tabPanel>
<apex:pageBlockSection title="Other Function">
<apex:form>
<apex:commandButton action="{!editToggle}" value="Toggle Account Edit" reRender="detailPageID" />
</apex:form>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Extension:
public class MyExtensionClass {
private final Account acc;
public boolean setEdit {get;set;}
public MyExtensionClass(ApexPages.StandardController stdController) {
system.debug('Inside Controller');
this.acc = (Account) stdController.getRecord();
setEdit = TRUE;
}
public void editToggle() {
system.debug('setEdit: ' + setEdit);
if (setEdit == TRUE) {
setEdit = FALSE;
}
ELSE
setEdit = TRUE;
}
}