+ Start a Discussion
sinsiterrulezsinsiterrulez 

NOT WORKING--Redirection to new page using Setredirect(false)

I have two visualforce pages that share the same controller. When the user goest to Page1 and meets specific criteria (defined in the Controller), I want Page1 to "skip" and have the user redirected to Page2. If the user doesn't meet the criteria, Page1 should appear.

 

I need to maintain the view state..I dont want to setredirect(true)..Does any one ahve any idea about it??

<apex:page controller="Enroll" action="{!SACCheck}">

 Here is the controller method

 

public Pagereference SACCheck()
    {
        Map<string,string> ServiceStat = new Map<string,string>();
        ServiceStat = obj.ServiceStat(opptyID);
        System.debug('ServiceStat: ' +ServiceStat);
        List<string> temp = new list<string>();
        temp.addall(ServiceStat.keyset());
        System.Debug('temp value: '+temp);
        
        if(!ServiceStat.isEmpty() && ServiceStat.size() < 2)
        {
            Requesttype = temp.get(0);
            System.debug(' Temps first value: ' +Requesttype);
            enroll = (ServiceStat.get(RequestType)== 'Request')? new Support_Request__c(Opportunity__c = opptyID,Request_Type__c = RequestType): [Select Support_Request_Type__c,Support_Request_Type_Others__c,Request_Type__c from Support_request__c where Opportunity__c=:opptyId and Request_Type__c =:RequestType limit 1];
            SupportReqd = (enroll.Support_Request_Type__c =='Support not Required')? TRUE : FALSE;            
            Pagereference data = new Pagereference('/apex/EnrollmentForm?id='+opptyid);
            data.setredirect(false);
            return data;
        }
        return null;        
    }

 

 

 

WesNolte__cWesNolte__c

Hey

 

Are the controllers and extensions exactly the same? Can you list the two pages too please.

 

Wes

sinsiterrulezsinsiterrulez

Hi The code for 2nd Page is as:

 

<apex:page controller="SAC_Enroll_PhaseIII" title="Request Support for: {!oppty.Name}" cache="false" showHeader="true" tabStyle="Support_Request__c" id="page" expires="0" sidebar="true">

 Both have same controller & no extensions.

 

WesNolte__cWesNolte__c

Sorry to be a pedant, but the first line of the first page (in your first post) has a different controller than the most recent post.

 

Wes

sinsiterrulezsinsiterrulez

Sorry I posted the wrong code. Here's the updated one:

 

<apex:page controller="Enroll" title="Request Support for: {!oppty.Name}" cache="false" showHeader="true" tabStyle="Support_Request__c" id="page" expires="0" sidebar="true">

 

 

WesNolte__cWesNolte__c

Hmmm.. there's nothing obviously wrong. I'd say that as a troubleshooting step move the page action method into a button. Let the page load and click the button to see if the "session" is maintained. 

 

I think we might have a Salesforce 'idiosyncracy' on our hands.

 

Wes

sinsiterrulezsinsiterrulez

HI,

Thanks for replyin..

I forgot to mention that instead of redirecting to next page which has the same controller if I redirect to some other VF page with different controller then it works perfectly fine!!!!

That's just bothering me!! I even tried deactivating the Development mode but it dint serve the purpose.

sinsiterrulezsinsiterrulez

I'm still stuck with that issue..Can anyone please help me on this??

SSRS2SSRS2

  Change the code as follows and try.I created sample for your scenario and it's work fine for me...

 

 

public Pagereference SACCheck()
    {
        Map<string,string> ServiceStat = new Map<string,string>();
        ServiceStat = obj.ServiceStat(opptyID);
        System.debug('ServiceStat: ' +ServiceStat);
        List<string> temp = new list<string>();
        temp.addall(ServiceStat.keyset());
        System.Debug('temp value: '+temp);
        
        if(!ServiceStat.isEmpty() && ServiceStat.size() < 2)
        {
            Requesttype = temp.get(0);
            System.debug(' Temps first value: ' +Requesttype);
            enroll = (ServiceStat.get(RequestType)== 'Request')? new  Support_Request__c(Opportunity__c = opptyID,Request_Type__c = RequestType): [Select Support_Request_Type__c,Support_Request_Type_Others__c,Request_Type__c from Support_request__c where Opportunity__c=:opptyId and Request_Type__c =:RequestType limit 1];
            SupportReqd = (enroll.Support_Request_Type__c =='Support not Required')? TRUE : FALSE;            
        }
        Pagereference data = new Pagereference('/apex/EnrollmentForm?id='+opptyid);
        data.setredirect(false);
        return data;        
    }

 

 -Suresh