3

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;
   }
  }
7
  • When you are being redirected is the page showing /apex/ in your URL? check if your save button is overriden with a custom vf page
    – Rao
    Jul 17 '14 at 17:06
  • OK. In URL , its showing ap1.salesforce.com/00T9000000s9Pvs .. So /apex/ is not showing.How can i check whether save button is overriden ?
    – JJoseph
    Jul 17 '14 at 17:23
  • go to setup --> create --> objectname --> buttons, links and actions and see if you can see the save button click edit and see override with = some VF page or scontrol
    – Rao
    Jul 17 '14 at 17:31
  • No Save button is not present there .? I do not know why my code is not working..
    – JJoseph
    Jul 17 '14 at 17:36
  • Is your page prompting to add more methods? looks like you are using a custom controller. when you use a custom controller you write your own edit,save modules
    – Rao
    Jul 17 '14 at 17:48
3

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();
    }

  }
1
  • Rao, you are champ.!!! Made it easy and simple.Thanks
    – JJoseph
    Jul 17 '14 at 18:54

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.