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
❤Code❤Code 

redirect to same page

Hi,

Could u please help me in the following scnearios - 

1. I have a vf page which displays list of cases with a picklist in each row and a save button. I want when i press save button it will save the record and redirect me to the same page. 

Currently i am not using any custom controller  and the save button after click is re-directing to home page.
Vinnie BVinnie B
I believe you have to use a controller (an Apex class designed to work with VF pages) to do much of anything with VF pages, including a redirect.  There are lots of examples online of code to do this.

I have a simple page that does some actions based on a button push, and then comes back to the original object page.  Each 'action' (i.e. button on a VF page) has its own function.  In my code, the function does a bunch of things and then calls this function as its last line. 

private pageReference returnToOrigination(){
    PageReference page = new PageReference('/' + orgDashboardID);
    page.setRedirect(true);
    return page;
  }
❤Code❤Code
Hi Vinnie,

I have tried using the following apex code . But i am getting the error . Please help - 

public class VioPage {
    ApexPages.StandardController stdCtrl;
    Public List <Violation__c> lead {get;set;}

    public VioPage(ApexPages.StandardSetController controller) {
        stdCtrl= controller;   //////////////////////////// Error: Compile Error: Illegal assignment from ApexPages.StandardSetController to ApexPages.StandardController at line 6 column 9
        lead = [SELECT Application__c,Business_Platform__c,Component__c,Severity__c,Status__c,Summary__c FROM Violation__c];
    }

    
     public PageReference save(){
      
        upsert lead;
     
        PageReference reRend = new PageReference('/apex/test8');
        reRend.setRedirect(true);
        return reRend;
    }

}

Regards
rsfdcrsfdc
Another approach would be to return null PageReference and use actionfuntion to "reRender" the page
❤Code❤Code
Hi,

Please find below my vf page code .Could you please suggest where can i modify.. Above is the controller

<apex:page standardController="Violation__c" recordSetVar="violations" tabStyle="Opportunity" sidebar="false"
extensions="VioPage ">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlock >
<apex:panelGrid columns="2">
<apex:outputLabel value="Severity Of Violation Selection:"/>
<apex:selectList value="{!filterId}" size="1">
<apex:actionSupport event="onchange" rerender="opp_table"/>
<apex:selectOptions value="{!listviewoptions}"/>
</apex:selectList>
</apex:panelGrid>
</apex:pageBlock>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!violations}" var="opp" id="opp_table">
<apex:column value="{!opp.Release_platform__c}"/>
<apex:column value="{!opp.Component__c}"/>
<apex:column headerValue="Stage">
<apex:outputField value="{!opp.Summary__c}"/>
</apex:column>
<apex:column headerValue="Line Number">
<apex:outputField value="{!opp.Line_Number__c}"/>
</apex:column>
<apex:column headerValue="Severity">
<apex:outputField value="{!opp.Severity__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:inputField value="{!opp.Status__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>


Vinnie BVinnie B
You've defined the stdCtrl variable to be a StandardController.  Yet you have a constructor which tries to take a StandardSetController and assign it to that variable. 
Vinnie BVinnie B
The problem probably lies in your controller code.  I usually find that my VF errors are just not calling the correct variable name from the controller.  :)  The error message you showed is clearly due to an error in your controller code.
❤Code❤Code
Hi Vinnie,

Should i remove the 

stdCtrl= controller;

Could you please help
Vinnie BVinnie B
The question is whether you want to use a StandardController or a StandardSetController.  The error message you received is due to your assigning one of those to the other type hence the "Illegal Assignment".

I don't know enough VF to give a good explanation of the differences between these two.  I'm sure there's online SFDC documentation on this.  I also don't know enough about what you're trying to do and which is the preferred.  If I had to guess, I would say use StandardController.
jeniffer homesjeniffer homes
Currently i am not using any custom controller  and the save button after click is re-directing to home page. (http://www.contacttelephonenumbers.com/)
❤Code❤Code
Hi Jeniffer,

Can u please share me the vf and the controller code if it is ok with you.

Regards