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

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. typename

    typename关键字是C++在标准化过程中被引入的,目的在于向编译器说明template内的某个标识符是个类型. 如:template <typename T> class MyClas ...

  2. HTTP1.1初识

    Http(超文本传输协议)是一个基于请求与响应模式的.无状态的.应用层的协议. Http1.1版中,有一个持续连接(Persistent Connections)机制,其作为Http1.1中建立连接的 ...

  3. 那年有关 return ; 的一切

    现在只知道在dev C++里面声明了函数的返回类型不为void就不能写return; ,但是如果返回值为void就可以写return; ,而且如你所愿.

  4. WWDC2016的一点个人想法

    看了游戏审核的新闻和WWDC,感觉个人游戏开发者会很难混下去了,WWDC里面iMessage 透露出来的信息,我感觉微信有竞争者了,假如苹果把iMessage 打造成微信那种模式(聊天+第三方接入), ...

  5. modal的使用

    $modal是一个可以迅速创建模态窗口的服务,创建部分页,控制器,并关联他们 $modal仅有一个方法open(options) templateUrl:模态窗口的地址 template:用于显示ht ...

  6. Sqlite 管理工具收藏

    1.SQLite Administrator   http://download.orbmu2k.de/files/sqliteadmin.zip 2.SQLite2009Pro-v3.8.3.1 h ...

  7. 模拟时钟(AnalogClock)和数字时钟(DigitalClock)

    Demo2\clock_demo\src\main\res\layout\activity_main.xml <LinearLayout xmlns:android="http://s ...

  8. python 之初体验

    python 关开python的介绍我这里就不解释了,这里贴出一个官方的介绍,供大家阅读 http://baike.baidu.com/link?url=U6LdVR-5RCI2TNsXzeALCcG ...

  9. 解剖SQLSERVER 第十篇 OrcaMDF Studio 发布+ 特性重温(译)

    解剖SQLSERVER 第十篇  OrcaMDF Studio 发布+ 特性重温(译) http://improve.dk/orcamdf-studio-release-feature-recap/ ...

  10. mac下android环境搭建笔记(android studio)

    本文记录了本人在mac上配置android开发环境的一些过程,为了方便直接选用了官方的IDE– Android Studio .本文包括了android studio的安装.创建第一个hello wo ...