+ Start a Discussion

Edit button not appearing

The Edit button only appears if the action and method is 'editMe' if they are named 'edit' the button no longer appears.


I have different page/class with the same edit method, is that the problem? The edit method needs to be uniquely named?


Here is the page:


<apex:page standardController="Service_Revnue_Forecast__c" extensions="ServiceForecast" title="Service Forecast" showHeader="true" sidebar="true"> <apex:detail relatedList="false" title="true"/> <apex:form > <apex:pageBlock title="Monthly Service Forecasts" id="gridform"> <apex:pageBlockButtons > <apex:commandButton action="{!saveForecasts}" value="Save" rendered="{!EditFlag}" id="SaveForecastButtonhhh" rerender="gridform" status="status"/> <apex:commandButton action="{!cancelEdit}" value="Cancel" rendered="{!EditFlag}" id="CancelForecastButton" rerender="gridform" status="status"/> <apex:commandButton action="{!editMe}" value="Edit" rendered="{!EditFlag == false}" id="EditForecastButton" rerender="gridform" status="status"/> </apex:pageBlockButtons> <apex:outputPanel id="viewTable" rendered="{!EditFlag == false}"> <apex:dataTable value="{!lForecasts}" var="item" id="ForecastTableView" rowClasses="odd,even" styleClass="" rules="rows" width="100%" > <apex:column headervalue="Forecast Name"><apex:outputLink value="/{!item.Id}" target="_self">{!item.name}</apex:outputLink></apex:column> <apex:column headervalue="Forecast"> <apex:outputField id="Forecast_Amount" value="{!item.Forecast__c}"/> </apex:column> <apex:column headervalue="Actual"> <apex:outputField id="Actual_Amount" value="{!item.Actual__c}"/> </apex:column> <apex:column headervalue="Comments"> <apex:outputText id="Comments" value="{!item.Comments__c}"/> </apex:column> <apex:column headervalue="Date" value="{!item.Date__c}"/> </apex:dataTable> </apex:outputPanel> <apex:outputPanel id="editTable" rendered="{!EditFlag}"> <apex:dataTable value="{!lForecasts}" var="item" id="ForecastTableEdit" rowClasses="odd,even" styleClass="" rules="rows" width="100%" > <apex:column headervalue="Forecast Name"> <apex:inputField id="Name" value="{!item.Name}"/> </apex:column> <apex:column headervalue="Bkgs Fcst Amt"> <apex:inputField id="Forecast_Amount" value="{!item.Forecast__c}"/> </apex:column> <apex:column headervalue="Comments"> <apex:inputText id="Comments" value="{!item.Comments__c}"/> </apex:column> </apex:dataTable> </apex:outputPanel> <apex:actionStatus id="status" startText="Requesting..." stopText="Data Retrieved!"/>&nbsp;{!StatusText} </apex:pageBlock> </apex:form> </apex:page>


 Here is the class:


public class ServiceForecast { String StatusText; public List<Monthly_Service_Revenue_Forecast__c> lForecasts; public Monthly_Service_Revenue_Forecast__c editForecast {get;set;} Boolean InsertFlag; public Boolean EditFlag {get;set;} private final Service_Revnue_Forecast__c SF; // Constuctor for extending the standard controller public ServiceForecast(ApexPages.StandardController stdController) { this.SF = (Service_Revnue_Forecast__c)stdController.getRecord(); StatusText = ''; lForecasts = ForecastList(); InsertFlag = false; EditFlag=false; } public String getParam(String name) { return ApexPages.currentPage().getParameters().get(name); } // Fill list with Forecasts public List<Monthly_Service_Revenue_Forecast__c> ForecastList(){ List<Monthly_Service_Revenue_Forecast__c> fl; try { fl = [Select c.id, c.Actual__c,c.Forecast__c, c.Date__c,c.Name, c.Comments__c from Monthly_Service_Revenue_Forecast__c c where c.Service_Revenue_Forecast__c = :SF.id]; } catch (QueryException e){ system.debug(e.getMessage()); StatusText = e.getMessage(); } return fl; } // Called from Grid to get List of Forecasts public List<Monthly_Service_Revenue_Forecast__c> getlForecasts () { if (InsertFlag){ lForecasts.add(new Monthly_Service_Revenue_Forecast__c(Service_Revenue_Forecast__c = SF.id)); InsertFlag = false; } return lForecasts; } // Called from Page to pass values from grid to controller public void setlForecasts(List<Monthly_Service_Revenue_Forecast__c> mf) { lForecasts = mf; } // Called from Page to get StatusText public String getStatusText() { return StatusText; } // Called from "Save" Button public PageReference saveForecasts () { try { upsert lForecasts; } catch (DMLException e) { system.debug(e.getMessage()); StatusText = e.getMessage(); } lForecasts = ForecastList(); EditFlag=false; return null; } // Called from "Add" Button public PageReference addForecast () { InsertFlag = true; return null; } public PageReference cancelEdit(){ EditFlag = false; return null; } public PageReference saveEdit() { try { UPDATE editForecast; editForecast = null; } catch (Exception e) { ApexPages.addMessages(e); } return null; } public PageReference editMe() { EditFlag = true; return null; } }


 Got it to work, just checking for my own edification.








I noticed the same issue where the Edit button disappeared when the action and method was named as 'edit'. I changed it to a possibly non conflicting method name and it started showing up. Looks like SF doesn't want us to use the standard controller default function names!



Paul BerglundPaul Berglund
Actually, a apex:form is in "edit" mode - so the action="{!edit}" will not display on the form.  If you added apex:commandButton for action="{!save}" and action="{!cancel}", you'll see that they do render.  You have to create controller methods called something other than the default to override this behavior.