通过 Visualforce 页面使用 Apex 刷新记录页面

问题描述 投票:0回答:1

我想创建一个按钮,它可以有效地执行与“ctrl r”相同的操作

我的最终用户完成 Visualforce 页面中的信息更新后。我想让他们选择单击此按钮,它将刷新嵌入 Visualforce 的整个记录页面。

老实说,我不知道该怎么做,我的编码经验有限。我唯一能做的就是在 Visualforce 页面中重新加载页面,但这并不是很有帮助。

这是我尝试过的:

Visualforce 代码:

<apex:page standardController="Request__c" extensions="ActionRelatedList">
    <apex:form>
        <apex:pageBlock>
            <apex:commandButton value="Reload" action="{!redirect}"/>
        </apex:pageBlock> 
    </apex:form>
</apex:page>

重定向方法:

    public PageReference redirect() {
        String requestURL ='URL';
    
        PageReference newRequestURL = new PageReference(requestURL);
        newRequestURL.setRedirect(true);
        return newRequestURL;
    }

但这不会刷新我的整个页面,它只是在 Visualforce 页面中打开它。

salesforce apex visualforce
1个回答
1
投票

您可以使用下面的代码来完成此操作:

<apex:page standardController="Account">
    <apex:form>
       <apex:pageBlock>
            <apex:commandButton value="Reload" onclick="window.top.location='/{!Account.id}';"/>
       </apex:pageBlock>
    </apex:form>
</apex:page>
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.