function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
S DS D 

Standard controller used but Save button redirects the page to another page

Hi
I am using the below code , and looking it to perform its standard function of saving the change and not redirecting .
I am new to visual force so still not able to understand the correct usage of reRender, as using it on my below  code,suffice the need of not redirecting it but in that case,changes are not saved. 

<apex:page standardController="Account" recordSetVar="records" id="thePage">
<apex:form id="theForm">
<apex:pageBlock id="thePageBlock">
<apex:outputPanel id="locationPicker">
<apex:pageBlockTable value="{!records}" var="record" id="thePageBlockTable">

<apex:column >
<apex:outputField value="{!record.Name}" id="AccountNameDOM" />
<apex:facet name="header">Name</apex:facet>
</apex:column>
<apex:column >
<apex:outputField value="{!record.Type}" id="AccountTypeDOM" />
<apex:facet name="header">Type</apex:facet>
</apex:column>
<apex:column >
<apex:outputField value="{!record.Industry}"
id="AccountIndustryDOM" />
<apex:facet name="header">Industry</apex:facet>
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
<apex:inlineEditSupport event="ondblClick"
showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />


<apex:pageBlockButtons >
<apex:commandButton value="Edit" action="{!save}" id="editButton"  />
<apex:commandButton value="Save" action="{!save}" id="saveButton"  reRender="locationPicker"/>
<apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

what shall be done to sort this out?
Pramod_SFDCPramod_SFDC
Hi,

Can you provide the code for the controller class named " Account"

Regards
Pramod
S DS D
i want it to use the "Save" functionality of the standardcontroller = "Account",so havent written a custom controller code. 

and this works also,but as i said redirects to another page. i.e home page rather than be on Account page.
Jim JamJim Jam
If you don't wish to redirect, use the quicksave method instead ..   <apex:commandButton value="Save" action="{!quicksave}" id="saveButton"  />

for reference: https://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_std_actions.htm 
S DS D
Thanks cmrc, its a good alternative when we use Save feature, however for a case like Cancel.  Action = {!cancel} or {!edit}  keeps redirecting.

Can the reRender option help in getting the reference back to the same page ,post a button click??  or any attribute that can redirec the control back to the same page??  

i have tried using the reRender in my code, but i am not aware if its a correct way to use.
Jim JamJim Jam
What are you expecting to happen when pressing Cancel or Edit ? By design, they should redirect I think. It doesn't male sense to press Cancel and just remain on the same page. Also, you are using a list table, it doesn't make sense to have an edit button, which record is it editing? 
Andy BoettcherAndy Boettcher
In order to change the location of the SSC {!save} method, you would need to include a controller extension with a method called "save" to override the SSC.  You can DML the SSC set and then construct a PageReference to send you back to wherever you want.
Aakaash NairAakaash Nair
Hi SD,

I had a chance to lok at this and faced the same behaviour.

Not sure if this is by design but as a workaround you can have an extension controller as below.

VF Page:
=============
<apex:page standardController="Account" extensions="testcontroller123" recordSetVar="records" id="thePage">

Note: I removed the outputpanel and the rerender

Controller:
===============
public class testcontroller123 {

    public testcontroller123(ApexPages.StandardSetController controller) {

    }
    public PageReference save()
     {
     return null;
}

}

I was able to inline edit and test it works.

You could try this for the others buttons as well.

Hope this helps!

If theree is another solution do let us know.

Please mark this as a best answer if your query  is resolved so others also get help from this thread in future.

Thanks,
Aakaash
S DS D
Aakash , Extending the controller does sort the issue.

However,  I feel then this solution contradicts to what salesforce says about Standard Controllers. As I understand, we need to use standard controller, when we Only want to use  basic features provided by it And no extra feature is required to go for a customization.

So  based on this understanding , when i am using standar controller = Account , with intension of using only basic feature then it should have worked without the support of extension.   so  now i am not getting the use of using Standard controllers over custom controller,when any ways we do need to customize the feature?

To be clear , I was expecting the below features of Standard Controller to behave as below:-----> 

1.  Edit button: When clicked,like in Account page should change the view to an editable mode.{but in here i am trying use it on a list view,with an expectation of working on multiple records]..though not sure how it would turn .

2. Save: should work in the same manner as save button of Account Page,without directing to any other page.

3. Cancel: should allow me to revert my inline-editing,without directing to any other page. Like what it supports as part of button on  standard Account Page.

CMRC, hope the above requirement clears what am i looking out for.