Have some strange behavior of the URL that gets displayed in my browser after redirecting between pages with a shared controller.
Reproducible Code
public with sharing class FooController {
//saves the quotes
public PageReference toFoo1(){
PageReference pr = Page.foo1;
pr.setRedirect(false);
return pr;
}
public PageReference toFoo2(){
PageReference pr = Page.foo2;
pr.setRedirect(false);
return pr;
}
}
<apex:page showHeader="true" sidebar="true" controller="FooController">
<apex:form>
<apex:commandButton styleClass="button quote-btn" value="to foo2" action="{!toFoo2}" />
</apex:form>
</apex:page>
<apex:page showHeader="true" sidebar="true" controller="FooController">
<apex:form>
<apex:commandButton styleClass="button quote-btn" value="to foo1" action="{!toFoo1}" />
</apex:form>
</apex:page>
After the first redirect, query params are dropped but the path does not change. However, if I redirect again, then the URL is then updated to the previous page.
Example:
- Starting on
/apex/Foo1?bar=abc
... - Click "To Foo2" button. URL now
reads
/apex/Foo1
- Click "To Foo1" button. URL now reads
/apex/Foo2
- Click "To Foo2" button. URL now reads
/apex/Foo1
Update
Setting redirect to true is not an option as I do not want my viewstate to change.
a
tags instead of commandbuttons. – Ralph Callaway May 24 '16 at 17:52