进行查询的情况下,显示友好的等待效果可以让用户更好的了解目前的状态以及减少用户消极的等待,例如下图所示。

VF提供了<apex:actionStatus>标签,,此标签用于显示一个AJAX请求更新的状态。一个AJAX请求状态可以显示为进展或完成。

实现上述效果的主要步骤如下:

1.创建一个Component:StatusSpinner.component

其中需要在salesforce中上传一个静态资源,显示loading的gif图片,有需要的可以进行下载:http://files.cnblogs.com/files/zero-zyq/loading.gif

 <apex:component >

 <apex:attribute name="Message"
type="String"
description="Messaging show in loading status spinner"
default="Loading..."/> <apex:actionStatus id="LoadingStatusSpinner">
<apex:facet name="start">
<div id="loadingDiv" class="loadingDiv" >
<span id="loadingHolder" class="loadingHolder">
<img class="loadingImage" title="Loading..." alt="Loading..." src="/img/loading.gif"/>
<span class="loadingDescription">{!message}</span>
</span>
</div>
</apex:facet>
</apex:actionStatus> <style>
.loadingImage { vertical-align:bottom; }.loadingDescription { padding:0 1.5em 0 0.5em; }
.loadingHolder {
background-color: #FFFFCC;
border: 1px solid #333333;
font-size: 1.2em;
font-weight: bold;
padding: 0.5em;
position: relative;
top: 45%;
white-space: nowrap;
}
.loadingDiv {
background-color: lightgrey;
opacity: .75;
filter: alpha(opacity=75); /* IE's opacity*/
text-align: center;
width: 100%;
height: 100%;
position: fixed;
z-index: 300;
top: 0;
left: 0;
} </style> </apex:component>

2.创建GoodsController

 public with sharing class GoodsController {

        public List<GOODS__c> goodsList{get;set;}

        //public GOODS__c goods{get;set;}

        public String goodsName{get;set;}
public Decimal goodsPriceStart{get;set;}
public Decimal goodsPriceEnd{get;set;} public String goodsDescribe{get;set;}
public GoodsController() {
goodsList = new List<GOODS__c>();
refreshData();
}
//刷新数据作用
public void refreshData() {
Boolean isStatus = true;
String goodsQueryString = 'SELECT GoodsBrand__c,'+
'GoodsDescribe__c,GoodsName__c, GoodsPrice__c,'+
' Id FROM Goods__c where IsDeleted = false limit 100';
goodsList = Database.query(goodsQueryString);
} public void query() {
String goodsSql = 'SELECT GoodsBrand__c,'+
'GoodsDescribe__c,GoodsName__c , GoodsPrice__c,'+
' Id FROM GOODS__c where IsDeleted = false ';
if(goodsName.length() >0) {
goodsName = '%' + goodsName + '%';
goodsSql += ' and GoodsName__c like :goodsName ';
}
if(goodsDescribe.length() > 0) {
goodsDescribe = '%' + goodsDescribe + '%';
goodsSql += ' and GoodsDescribe__c like :goodsDescribe';
} if(String.valueOf(goodsPriceStart).length()>0) {
goodsSql += ' and GoodsPrice__c >= :goodsPriceStart';
}
if(String.valueOf(goodsPriceEnd).length()>0) {
goodsSql += ' and GoodsPrice__c <= :goodsPriceEnd';
}
goodsSql += ' limit 100';
goodsList = Database.query(goodsSql);
goodsName = goodsName.remove('%');
goodsDescribe = goodsDescribe.remove('%');
}
}

3.创建GoodsListPage:页面中将Component引入进来,然后在apex:commandButton标签上绑定action,设置status值,status值为apex:actionStatus的Id,设置reRender为table的Id,以便查询后重新渲染table列表。

 <apex:page controller="GoodsController" showHeader="false">

     <c:StatusSpinner />
<apex:messages />
<apex:form >
<apex:pageBlock title="GOODS" id="page">
<apex:pageBlockSection title="query goods">
<apex:inputText value="{!goodsName}" label="goodsName"
id="goodsName" />
<apex:inputText value="{!goodsPriceStart}"
label="goodsPriceStart" />
<apex:inputText value="{!goodsPriceEnd}"
label="goodsPriceEnd" />
<apex:inputText value="{!goodsDescribe}"
label="goodsDescribe" />
<apex:commandButton value="query" action="{!query}" status="LoadingStatusSpinner" reRender="resultGoods"/>
</apex:pageBlockSection> <apex:pageBlockTable value="{!goodsList}" var="goods" id="resultGoods">
<apex:column headervalue="goodsName">
<apex:outputField value="{!goods.GoodsName__c}"/>
</apex:column>
<apex:column headervalue="goodsPrice">
<apex:outputField value="{!goods.GoodsPrice__c}" />
</apex:column>
<apex:column headervalue="goodsDescribe">
<apex:outputField value="{!goods.GoodsDescribe__c}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

通过以上三个步骤,便可以实现查询显示等待效果。

总结:apex:actionStatus可以相对较好的显示等待(loading)效果,不过相关限制较多,需要相关commandButton等标签提供reRender属性。比如不能在inputFile中使用此标签因为inputFile的页面不能reRender,如果类似上面demo中简单的查询或者ajax请求进行查询可以使用此种方式,如果存在inputFile的页面,慎用。

salesforce 零基础学习(二十七)VF页面等待(loading)效果制作的更多相关文章

  1. 【转】【Salesforce】salesforce 零基础学习(十七)Trigger用法

    看本篇之前可以相应阅读以下Trigger相关文章: 1.https://developer.salesforce.com/page/Trigger_Frameworks_and_Apex_Trigge ...

  2. salesforce 零基础学习(十七)Trigger用法

    看本篇之前可以相应阅读以下Trigger相关文章: 1.https://developer.salesforce.com/page/Trigger_Frameworks_and_Apex_Trigge ...

  3. salesforce 零基础学习(五十二)Trigger使用篇(二)

    第十七篇的Trigger用法为通过Handler方式实现Trigger的封装,此种好处是一个Handler对应一个sObject,使本该在Trigger中写的代码分到Handler中,代码更加清晰. ...

  4. salesforce零基础学习(八十二)审批邮件获取最终审批人和审批意见

    项目中,审批操作无处不在.配置审批流时,我们有时候会用到queue,related user设置当前步骤的审批人,审批人可以一个或者多个.当审批人有多个时,邮件中获取当前记录的审批人和审批意见就不能随 ...

  5. salesforce零基础学习(八十七)Apex 中Picklist类型通过Control 字段值获取Dependent List 值

    注:本篇解决方案内容实现转自:http://mysalesforceescapade.blogspot.com/2015/03/getting-dependent-picklist-values-fr ...

  6. salesforce零基础学习(八十九)使用 input type=file 以及RemoteAction方式上传附件

    在classic环境中,salesforce提供了<apex:inputFile>标签用来实现附件的上传以及内容获取.salesforce 零基础学习(二十四)解析csv格式内容中有类似的 ...

  7. salesforce零基础学习(八十)使用autoComplete 输入内容自动联想结果以及去重实现

    项目中,我们有时候会需要实现自动联想功能,比如我们想输入用户或者联系人名称,去联想出系统中有的相关的用户和联系人,当点击以后获取相关的邮箱或者其他信息等等.这种情况下可以使用jquery ui中的au ...

  8. salesforce零基础学习(九十六)Platform Event浅谈

    本篇参考:https://developer.salesforce.com/blogs/2018/07/which-streaming-event-do-i-use.html https://trai ...

  9. salesforce零基础学习(一百一十)list button实现的一些有趣事情

    本篇参考: salesforce零基础学习(九十五)lightning out https://developer.salesforce.com/docs/component-library/docu ...

  10. salesforce 零基础学习(六十八)http callout test class写法

    此篇可以参考: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restfu ...

随机推荐

  1. lua 自己编译源文件

    ,下载源代码 http://www.lua.org/download.html 直接下载source ,vs2010新建win32项目 应用程序设置中设成静态库 ,将.c(除去lua.c)和.h文件加 ...

  2. JS-reverse(数组内容颠倒)

    var arr1 = [ 1,2,3,4,5,6 ];// arr1.reverse();// alert( arr1 ); //怎么颠倒字符串呢? var str = 'abcdef';alert( ...

  3. tmpfs介绍

    tmpfs 前几天发现服务器的内存(ram)和swap使用率非常低,于是就想这么多的资源不用岂不浪费了?google了一下,认识了tmpfs,总的来说tmpfs是一种虚拟内存文件系统正如这个定义它最大 ...

  4. Red Hat Enterprise Server 5.8+oracle10g(中文界面)安装

    Red Hat Enterprise Server 5.8+oracle10g(中文界面)安装 VMware workstation10(虚拟机)下面安装红帽企业版5.8 创建虚拟机 新建虚拟机,选择 ...

  5. CAD2012安装错误

    安装CAD2012总是会出现各种错误,不能安装,特别是.NET Framework Runtime 4.0安装错误. 单独安装dotNetFx40_Full_x86_x64.exe会提示更高级的版本已 ...

  6. js组件之间的通信

    应用场景: 1.在刷微博的时候,滑到某个头像上,会出现一张usercard(用户名片), 微博列表区有这个usercard, 推荐列表也有这个usercard,评论区也有. 2.在网上购物时,购物车安 ...

  7. 转 :meta name的含义:<META http-equiv=Content-Type content="text/html; charset=gb2312">

    meta是什么?meta其实是html语言head区的一个辅助性标签.在几乎所有的网页里,我们都可以看到类似下面这段html代码:<META http-equiv=Content-Type co ...

  8. CAS 4.0.0RC编译环境

    CAS 4.0.0RC编译环境 Eclipse Java EE IDE for Web Developers. JDK1.7,注意用JDK1.8是会出现编译错误的. Maven 在编译出现test错误 ...

  9. CCNA第二章TCP/IP简介考试要点学习笔记

    1.描述网络是如何工作的     DoD过程/应用层 -- OSI应用.表示和会话层(定义了结点到结点的应用通信协议以及对用户界面规范的控制): DoD主机到主机层 -- OSI传输层(保证了数据包的 ...

  10. td标签内的内容过长导致的问题的解决办法

    问题描述:在开发过程中,td标签中的有一个cell格中的内容过长,导致td标签高度增加,从而导致整个页面内容的不协调: