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
Vivek ViswanathVivek Viswanath 

how do i Redirect on page load?

Hi I have a controller function that I call on page load and i also Have a condition specified which if satisfied it returns another PageReference however it dosent show the page. when I use the command with a command button it works.

public PageReference SFDCRegKitController() // This is my function
        {
              
               setOpportunityId();
                setCampaignId();
                getData.poplulateRegistritationKitItemsList(campaignId);
                getData.populateOpportunity(this.opportunityId);
               
                if( getData.changeToReOrderScreen == true)
                {
                    return Page.reg_re_order;//registrationKitReOrder(); // this is the page I want to go to.
                }
                return null;
                //getData.populateOrderItemList();
                
        }

This is my page I put in debug statements and it goes into that part of the code and also returns the page. However its not displayed. Please let me know what I am doing wrong here

<apex:page controller="SFDCRegKitController" action="{!SFDCRegKitController}" >
</apex:page>


Message Edited by Vivek Viswanath on 07-22-2008 06:15 AM
Sam.arjSam.arj
I am not sure if I understood your question correctly but in order to redirect your page you should do the following:

public PageReference SFDCRegKitController()
{

      ....

      String url = {your url};
      PageReference p = new PageReference(url);
      return p;
}


Most probably "Page.reg_re_order" merely returns the url of the other page.
Good luck

hisrinuhisrinu
Hi,

Call this function on page load.
<apex:page ............   action="{!methodname}">
write your markup here

</apex:page>

This will work.
Vivek ViswanathVivek Viswanath
My issue is that

<apex:page controller="SFDCRegKitController" action="{!SFDCRegKitController}" >
...
</apex:page>


dosent work  and yes PageReference pageRef = ApexPages.currentPage(); dosee give me back a page reference.

Regards

Vivek


jwetzlerjwetzler
There's a known issue with forwarding from the action attribute in your page reference. You have to do a redirect instead.  So grab your PageReference and call setRedirect(true) on it before you return.
Vivek ViswanathVivek Viswanath
Hi All

I Think this will be simpler the re-direct worked however the data behind it is not being shared any ideas on that?

Regards

Vivek

Message Edited by Vivek Viswanath on 07-22-2008 09:14 AM
Vivek V.ax312Vivek V.ax312
Hi All

I Think this will be simpler the re-direct worked however the data behind it is not being shared any ideas on that?

Regards

Vivek