salesforce pagereference 和接收url上传递的参数

本文详细介绍了Salesforce中PageReference的使用方法及其属性和方法,包括如何创建PageReference实例、设置重定向、获取页面内容等,并提供了实际应用场景的示例代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_system_pagereference.htm  salesforce 官方介绍 pagereference

pagereference

   fullURL可以是一个完整的链接地址。也可以是一个相对路径。

  也可以通过url中传递链接参数。string fullURL = 'http://www.baidu.com/s?wd=a';a 可以当做一个参数传递进去。

代码如下:

  PageReference pageRef = new PageReference('fullURL');

这个方法中  PageReference acctPage = new ApexPages.StandardController(account).view(); 默认调转到account默认的视图中(在pagelayout中自定义按钮中会用到这个方法)。 setRedirect(Boolean) Sets the value of the PageReference object's redirect attribute. If set to true, a redirect is performed through a client side redirect.意思是说,设置成true,直接就从客户端跳转了。

 public PageReference save() {
        // Add the account to the database. 
        insert account;
        // Send the user to the detail page for the new account.
        PageReference acctPage = new ApexPages.StandardController(account).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
PageReference Instance Methods
getAnchor()
Returns the name of the anchor referenced in the page’s URL. That is, the part of the URL after the hashtag (#).
getContent()
Returns the output of the page, as displayed to a user in a Web browser.
getContentAsPDF()
Returns the page as a PDF, regardless of the <apex:page> component's renderAs attribute.
getCookies()
Returns a map of cookie names and cookie objects, where the key is a String of the cookie name and the value contains the list of cookie objects with that name.
getHeaders()
Returns a map of the request headers, where the key string contains the name of the header, and the value string contains the value of the header.
getParameters()
Returns a map of the query string parameters that are included in the page URL. The key string contains the name of the parameter, while the value string contains the value of the parameter.
getRedirect()
Returns the current value of the PageReference object's redirect attribute.
getUrl()
Returns the relative URL associated with the PageReference when it was originally defined, including any query string parameters and anchors.
setAnchor(String)
Sets the URL’s anchor reference to the specified string.
setCookies(Cookie[])
Creates a list of cookie objects. Used in conjunction with the Cookie class.
setRedirect(Boolean)
Sets the value of the PageReference object's redirect attribute. If set to true, a redirect is performed through a client side redirect.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

高远的理想

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值