首页 技术 正文
技术 2022年11月17日
0 收藏 655 点赞 3,123 浏览 3022 个字

salesforce给我们提供了标准的页面,比如标准的页面包括标准的列表和标准的详细页视图。有的时候我们想要自定义视图,比如做一个项目的时候不希望使用者直接通过ID查看到标准的详细页,而是跳转到指定处理过的详细页,这个时候做法如下:

salesforce 零基础学习(五十)自定义View或者List以及查看系统原来的View或者List

1.创建相关详细页的Controller,此Controller的构造函数应涵盖ApexPages.StandardController,ApexPages.StandardSetController两个参数

 public without sharing class CompanyDetailController {
private Map<String,String> params; public Company_Info__c companyInfo{get;set;} public CompanyDetailController(ApexPages.StandardController controller) {
init();
} public CompanyDetailController(ApexPages.StandardSetController controller) {
init();
} public void init() {
params = ApexPages.currentPage().getParameters();
String companyInfoId = params.get('id');
String fetchCompanyInfo = 'SELECT Company_Code_Unique__c, Company_Name__c, Company_Phone__c, Company_Place__c, Company_Type__c, CreatedDate,Employees_Number__c, Id FROM Company_Info__c where Id = :companyInfoId';
List<Company_Info__c> companyInfoList = Database.query(fetchCompanyInfo);
if(companyInfoList == null || companyInfoList.size() == 0) {
companyInfo = null;
} else {
companyInfo = companyInfoList.get(0);
}
}
}

CompanyDetailController

2.创建相应的page,此page用于显示view的布局

 <apex:page standardController="Company_Info__c" extensions="CompanyDetailController">
<apex:pageBlock >
<apex:panelGrid columns="2" style="width:100%;" rendered="{!companyInfo == null}">
不存在此ID对应的记录,请重新检查相关ID
</apex:panelGrid>
<apex:panelGrid columns="2" style="width:100%;" rendered="{!companyInfo != null}">
<apex:outputLabel value="{!$ObjectType.Company_Info__c.Fields.Company_Code_Unique__c.Label}" style="color: #830051;line-height: 24px;"/>
<apex:outputLabel value="{!companyInfo.Company_Code_Unique__c}"/> <apex:outputLabel value="{!$ObjectType.Company_Info__c.Fields.Company_Name__c.Label}" style="color: #830051;line-height: 24px;"/>
<apex:outputLabel value="{!companyInfo.Company_Name__c}"/> <apex:outputLabel value="{!$ObjectType.Company_Info__c.Fields.Company_Phone__c.Label}" style="color: #830051;line-height: 24px;"/>
<apex:outputLabel value="{!companyInfo.Company_Phone__c}"/> <apex:outputLabel value="{!$ObjectType.Company_Info__c.Fields.Company_Place__c.Label}" style="color: #830051;line-height: 24px;"/>
<apex:outputLabel value="{!companyInfo.Company_Place__c}"/> <apex:outputLabel value="{!$ObjectType.Company_Info__c.Fields.Company_Type__c.Label}" style="color: #830051;line-height: 24px;"/>
<apex:outputLabel value="{!companyInfo.Company_Type__c}"/> <apex:outputLabel value="{!$ObjectType.Company_Info__c.Fields.Employees_Number__c.Label}" style="color: #830051;line-height: 24px;"/>
<apex:outputLabel value="{!companyInfo.Employees_Number__c}"/>
</apex:panelGrid>
</apex:pageBlock>
</apex:page>

CompanyDetailPage

3.修改Company Info这个object的view,修改成override with visualforce Page

salesforce 零基础学习(五十)自定义View或者List以及查看系统原来的View或者List

4.显示效果:当在窗口输入:https://c.ap2.visual.force.com/a032800000JG8c0AAD访问以后会自动跳转到

https://c.ap2.visual.force.com/apex/CompanyDetailPage?id=a032800000JG8c0AAD&sfdc.override=1

salesforce 零基础学习(五十)自定义View或者List以及查看系统原来的View或者List

通过以上几步可以实现自定义view的操作。那么问题来了,如果我是admin,我想通过这条记录ID,查看他的原始信息,查看他的审批流程,但是这条记录的view视图已经被override了怎么办,可以采用此种操作进行查看原始的记录view视图。

https://ap2.salesforce.com/a032800000JG8c0AAD?nooverride=1    此种访问便可以显示原来的view视图

salesforce 零基础学习(五十)自定义View或者List以及查看系统原来的View或者List

总结:此篇主要想强调的是view视图被override以后想要看原始的视图方式,相信很多人都会,在此写成一篇博客,方便自己以后忘记时查看,此篇如果有错误的地方欢迎指正,有不懂的地方欢迎留言。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,078
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,553
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,402
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,177
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,814
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898