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;
}
  • 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 '19 at 13:32
  • Not even that... – Robert Sösemann Jul 23 '19 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 '19 at 15:10
  • No that doesn't make a difference. – Robert Sösemann Jul 23 '19 at 20:02
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;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.