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

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. Dojo框架学习笔记<二>

    一.dojo/dom    该模块定义了Dojo Dom API,主要有以下几种用法:    1.dom.byId();(相当于document.getElementById())    ①最直接的用 ...

  2. Debian配置Apache2支持mod-python和cgi模块

    Ubuntu好像是直接支持的,现在回到Debian有点不适应了.需要人工配置一下: 一.mod-python 安装模块:apt-get install libapache2-mod-python 编辑 ...

  3. 谷歌CEO发布年度公开信:专注人工智能等6大业务领域

  4. 原生js-日历插件

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  5. Django-数据模型

    修改model.py文件 from django.db import models # Create your models here. class Question(models.Model): q ...

  6. poi解析excel 03、07

    maven依赖 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</a ...

  7. 关于“windows无法自动将ip协议栈绑定到网络适配器”问题导致不能连上网的解决办法

    问题出现的原因:这个问题的直接表象并不是显示给用户这个问题,而是提示无线网络驱动可能有问题或者以太网驱动可能有问题,但只要用户查看”详细信息“,就会得到标题这个问题,而出现这个问题的本质并不是驱动问题 ...

  8. Eclipse不能自动编译 java文件

      在网上的解决方法 方法参考如下: (1) Window-->Preferences-->General-->Workspace  有个"Build automatica ...

  9. Android JIT实时编译器的设置

    在Android  JIT实时编译是在Android 2.2之后才引入的,JIT编译器可以显著的提高机器的性能,经过测试,android 2.2的性能较android 2.1提高了 2-5倍.JIT提 ...

  10. Android—LayoutInflater学习笔记

    LayoutInflater的的主要用处:使用LayoutInflater来载入界面,类似于findViewById()在Activity中加载Widget组件一样.区别在于与LayoutInflat ...