[SalesForce] inline edit not saving records

The inline edit is not working properly. On clicking Save, it takes me to another page but does not save the edit . Thanks in advance

  <apex:page controller="SearchController">
  <apex:form id="searchForm">
  <apex:PageBlock mode="edit">     
         <apex:pageBlockButtons >
            <apex:commandButton action="{!edit}" id="editButton" value="Edit"/>
            <apex:commandButton action="{!save}" id="saveButton" value="Save"/>
            <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
        </apex:pageBlockButtons>
       <apex:inlineEditSupport showOnEdit="saveButton, cancelButton"
                 hideOnEdit="editButton" event="ondblclick"
                    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>

     <apex:pageblockSection id="searchBlockSection">
     <apex:pageBlockSectionItem id="searchBlockSectionItem">
     <apex:outputLabel >Keyword</apex:outputLabel>
        <apex:panelGroup >
            <apex:inputtext id="searchTextBox" value="{!searchText}">
            </apex:inputtext>
            <apex:commandButton Id="btnSearch" action="{!Search}" rerender="renderBlock" status="status" title="Search" value="Search">      
          </apex:commandButton>
        </apex:panelGroup>
    </apex:pageBlockSectionItem>
</apex:pageblockSection>
<apex:actionStatus id="status" startText="Searching... please wait..."/>     
<apex:pageBlocksection id="renderBlock" >
    <apex:pageblocktable value="{!SearchResults}" var="o" rendered="{!NOT(ISNULL(SearchResults))}">
        <apex:outputLink value="/{!o.Id}">{!o.Subject}</apex:outputLink>
        <apex:column value="{!o.Subject}"/>
        <apex:outputLink value="/{!o.Id}">{!o.Status}</apex:outputLink>
        <apex:column value="{!o.Status}"/>
     </apex:pageblocktable>    
    </apex:pageBlocksection>
  </apex:pageblock>
  </apex:form>
 <apex:enhancedlist type="Activity" height="800" rowsPerPage="50" customizable="False"/>

 public class SearchController
{
   public apexpages.standardController controller{get;set;}
   public Task l;
   public List<Task> searchResults {get; set; }

  public string searchText
  {
   get
   {
     if (searchText==null) searchText = '';
     return searchText;
   }
  set;
   }

 public SearchController(ApexPages.StandardController controller)
 {
    this.controller = controller;
    this.l = (Task) controller.getRecord();
  }

public PageReference search()
{
  if(SearchResults == null)
  {
    SearchResults = new List<Task>();
  }
 else
 {
    SearchResults.Clear();
 }

    String qry ='Select Id,Subject,Status from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\' Order By Subject,Status';

  SearchResults = Database.query(qry);
  return null;
   }
  }

Best Answer

Modified your code: Page:

<apex:page controller="SearchController">
  <apex:form id="searchForm">
  <apex:PageBlock mode="edit">     
         <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" id="saveButton" value="Save"/>
            <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
        </apex:pageBlockButtons>
       <apex:inlineEditSupport showOnEdit="saveButton, cancelButton"
                 hideOnEdit="editButton" event="ondblclick"
                    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>

     <apex:pageblockSection id="searchBlockSection">
     <apex:pageBlockSectionItem id="searchBlockSectionItem">
     <apex:outputLabel >Keyword</apex:outputLabel>
        <apex:panelGroup >
            <apex:inputtext id="searchTextBox" value="{!searchText}">
            </apex:inputtext>
            <apex:commandButton Id="btnSearch" action="{!Search}" rerender="renderBlock" status="status" title="Search" value="Search">      
          </apex:commandButton>
        </apex:panelGroup>
    </apex:pageBlockSectionItem>
</apex:pageblockSection>
<apex:actionStatus id="status" startText="Searching... please wait..."/>     
<apex:pageBlocksection id="renderBlock" >
    <apex:pageblocktable value="{!SearchResults}" var="o" rendered="{!NOT(ISNULL(SearchResults))}">
        <apex:column headervalue="Id">
        <apex:outputLink value="/{!o.Id}" target="_blank">{!o.Id}
        </apex:outputLink>      
        </apex:column>

        <apex:column headervalue="Subject">
        <apex:outputfield value="{!o.Subject}"/>
        </apex:column>
        <apex:outputLink value="/{!o.Id}">{!o.Status}</apex:outputLink>
        <apex:column value="{!o.Status}"/>
     </apex:pageblocktable>    
    </apex:pageBlocksection>
  </apex:pageblock>
  </apex:form>
 <apex:enhancedlist type="Activity" height="800" rowsPerPage="50" customizable="False"/>
 </apex:page>

controller:

public class SearchController
{
   public Task l;
   public List<Task> searchResults {get; set; }
   public SearchController() {

   }

  public string searchText
  {
   get
   {
     if (searchText==null) searchText = '';
     return searchText;
   }
  set;
   }

    public PageReference search()
    {
        if(SearchResults == null)
        {
            SearchResults = new List<Task>();
        }
        else
        {
            SearchResults.Clear();
        }
        String qry ='Select Id,Subject,Status from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\' Order By Subject,Status';   
        SearchResults = Database.query(qry);
    return null;
    }

   public PageReference save() {
   update SearchResults ; 
      return ApexPages.CurrentPage();
    }

  }
Related Topic