3

I have a Visualforce page + component

<apex:component allowDml="true">

    <apex:form id="form">
        <apex:commandButton action="{!step.run}" rerender="form" status="loading" />
        ...
    </apex:form>
</apex:component>

with and apex:commandButton calling Apex which when execute should reload the page.

But no matter what I return it's not reloading the page.

public override PageReference run() {
    ...
    return Page.samePage;
}

or

public override PageReference run() {
    ...
    return null;
}

or

public override PageReference run() {
    ...
    PageReference samePage = ApexPages.currentPage();
    samePage.setRedirect(true);
    return samePage;
}
4
  • 1
    with reerender attribute on command button, it performs a partial referesh of specified component/tag Id. But atleast there should be a redirection to new page with return Page.samePage;.
    – Raul
    Jul 23, 2019 at 13:32
  • Not even that... Jul 23, 2019 at 15:05
  • 1
    Does it matter if the redirect is executed from the component or visualforce, trying to think and isolate the problem here.
    – Raul
    Jul 23, 2019 at 15:10
  • No that doesn't make a difference. Jul 23, 2019 at 20:02

2 Answers 2

1

Can you try and check if any of below options is working:

  1. Remove rerender in button - this will not reload page normally also. (rerender="form")
  2. Try returning PageRef.getUrl(). So return type of method will be string. And in Javascript, do window.open(url,"_self").
0

Don't ask me why but this worked. Even with the rerender.

public override PageReference run() {
    ...
    PageReference samePage = Page.samePage;
    samePage.setRedirect(true);
    return samePage;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .