您的位置:首页 > Web前端

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

2013-12-21 21:04 387 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: