Dev401-025:Visualforce Pages: JavaScript in Visualforce

Module Objectives
1.Describe the use of AJAX within Visualforce.
2.Create access to standard actions via the $URLFOR expression.
3.Create reusable functions within ,script> tags.
4.Create partial page refreshes on javaScript events.
5.Describe the usage of the AJAX action components.

Module Agenda
1.Action Biding and javaScript
2.JavaScript Functions
3.Partial page Updates
4.Asymchronous Operation Status
5.AJAX Behavior on Events

Using JavaScript to Reference Components
1.Every Visualforce tag has an id attribute. The id attribute for a tag can be used by another tag to bind the two tags together. For example, the <apex:outputLabel> tag’s for attribute can be used with the <apex:inputField> tag’s id attribute. The reRender and status attributes on <apex:actionFunction>, <apex:actionSupport>, and other action-oriented components also use the value of the id attribute from other components.
2.In addition to being used to bind Visualforce components together, this ID is used to form part of the document object model (DOM) ID for the component when the page is rendered.
3.To refer to a Visualforce component in JavaScript or another Web-enabled language, you must specify a value for the id attribute for that component. A DOM ID is constructed from a combination of the id attribute of the component and the id attributes of all components that contain the element.

Using a JavaScript Library with Visualforce
1.You can include JavaScript libraries in your Visualforce pages to take advantage of functionality provided by these libraries.
2. The best way to include JavaScript libraries is by creating a static resource, and then including the library by adding an <apex:includeScript> component to your page.
3.For example, if you are using MooTools (http://mootools.net/), create a static resource from the library called mootools, and then reference it in a page like this:
<apex:page>
  <apex:includeScript value="{!$Resource.mootools}"/>
</apex:page>

Apex:actionStatus
1.A component that displays the status of an AJAX update request. An AJAX request can either be in progress or complete.
2.Example
<!--  Page: -->
                        
<apex:page controller="exampleCon">
    <apex:form>
        <apex:outputText value="Watch this counter: {!count}" id="counter"/>
        <apex:actionStatus startText=" (incrementing...)"
            stopText=" (done)" id="counterStatus"/>
        <apex:actionPoller action="{!incrementCounter}" rerender="counter"
            status="counterStatus" interval="15"/>
    </apex:form>
</apex:page>

/*** Controller: ***/

public class exampleCon {
    Integer count = 0;
                        
    public PageReference incrementCounter() {
            count++;
            return null;
    }
                        
    public Integer getCount() {
        return count;
    }
}

Visualforce Components & javaScript Events
1.Many Visualforce tags relate to different UI components.
2.These often have attributes equivalent to JavaScript events to handle user actions to those components.

Partial page Refreshes for Conditional Fields
1.Goal(s)
- Override the position new page to only display certain fields based on the values of others, and refresh only the part of the page taht is required.
2.Scenarion:
- Universal Containers wants to provide a similar functionality to record types in providing different fields on the page depending on the values of the others. However,with Visualforce they have heard that they can not only make this dynamic, but also so thatit only requires a partial page refresh.
- The postion page should only display the Technical Skills section when the Department is set to IT or Engineering.
3.Tasks:
- Add the pre-existing visualforce page to your org.
- Override te Position New button.
- Test the page.

Module Review
1.What are soem examples of JavaScript Events?
2.What is AJAX typically used for in Visualforce?How this different from s-controls?
partial page refresh
3.Why would you need to use the global $URLFOR variable?
4.What is the purpose of script tags?
5.What are the different AJAX action tags? What does each do?
6.How can you create partial page refreshes? How does the method change depending on the context?

Building Applications with Force.com and VisualForce (DEV401) (二四):JavaScript in Visualforce的更多相关文章

  1. Building Applications with Force.com and VisualForce(Dev401)(十八):Visualforce Pages: Introduction to Visualforce

    Dev401-020:Visualforce Pages: Introduction to Visualforce Course Objectives1.Understand the benefits ...

  2. Building Applications with Force.com and VisualForce(Dev401)(十):Designing Applications for Multiple Users: Building Business Processes that You Want

    Dev401-011: Building Business Processes that You Want Course Objectives1.Describe the capabilities o ...

  3. Building Applications with Force.com and VisualForce (DEV401) (四):Building Your user Interface

    Dev 401-004:Application essential:Building Your user Interface: Module Agenda1.Custom Applications2. ...

  4. Building Applications with Force.com and VisualForce (DEV401) (三):Application Essential:Building Your Data Model

    Dev 401-003:Application Essential:Building Your Data Model Object Relationships1.Link two objects- P ...

  5. Building Applications with Force.com and VisualForce (DEV401) (二) : Application Essentials:Designing Application on the Force.com Platform

    Dev 401-002:Application Essentials:Designing Application on the Force.com Platform Course Objectives ...

  6. Building Applications with Force.com and VisualForce(Dev401)(七):Designing Applications for Multiple users:Managing your users' experience I

    Dev 401-007 Designing Applications for Multiple users: Managing your users' experience part 1 Module ...

  7. Building Applications with Force.com and VisualForce (DEV401) (二五):Visualforce Controller

    Dev401-026:Visualforce Pages: Visualforce Controller   Module Objectives1.Identify the functionality ...

  8. Building Applications with Force.com and VisualForce (DEV401) (二一):Visualforce Componets (Tags) Library Part 1

    Dev401-022:Visualforce Pages: Visualforce Componets (Tags) Library Part 1 Module Objectives1.List ke ...

  9. Building Applications with Force.com and VisualForce (DEV401) (二三):Visualforce Componets (Tags) Library Part III

    Dev401-024:Visualforce Pages: Visualforce Componets (Tags) Library Part IIIStatic Resources1.Static ...

随机推荐

  1. 阿里为何要用独立APP挖微信微商墙角?

    ​ 微商,这个被很多人看来是逃离马云魔咒,和淘宝抗衡的电商模式,自诞生到狂飙就伴随着种种争议.由于传播效率极强,在很长时间里也一直是不少人口中津津乐道的神话故事和救市良方.以至于,淘宝推出各种手段封杀 ...

  2. mongodb 修改oplogSize

    oplog是local库下的一个固定集合,Secondary就是通过查看Primary的oplog这个集合来进行复制的.每个节点都有oplog,记录从主节点复制过来的信息,这样每个成员都可以作为同步源 ...

  3. 10分钟进阶SpringBoot - 05. 数据访问之JDBC(附加源码分析+代码下载)

    10分钟进阶SpringBoot - 05. 数据访问之JDBC 代码下载:https://github.com/Jackson0714/study-spring-boot.git 一.JDBC是什么 ...

  4. Java程序员考研失败后的面试经历,oppo、VIVO、等面经

      温馨提示:有些可能会遗漏个别问题,都是最近一周的面试,有点忘了. 浪潮(一面挂) 你是网络工程的?对网络很了解? 解释一下什么是广播域 怎么划分子网 说一下CSS的几种分类器 数据库中有哪些聚集函 ...

  5. redis01

    1.redis 1)cookie与session session本质上也是cookie,cookie携带session返回给服务端 redis是一个存储数据库 redis读写快速,使用简单,常用于存储 ...

  6. js监听离开或刷新页面时的弹窗提示

    一.看图 二.使用场景. 填写表单时内容,当离开页面或者刷新的时候回丢失页面的内容,因此人性化的设计该有一个提示.所以这样的功能也就应用而生了. 三.思路. 1,页面内容改变.2,离开或刷新浏览器触发 ...

  7. All In One

    set1 https://github.com/tianhang-f... set2 https://github.com/tianhang/F... set3https://github.com/t ...

  8. 服务器推送 SSE 了解一下?

    hello~亲爱的看官老爷们大家好~过完年第一周已经结束,是时候开始制定新的工作计划了.主要负责的项目是数据可视化平台,而使用中如果服务器能有推送能力让页端得到相关通知的话,就能实现很多功能上的优化. ...

  9. js获取当前日期是一年中的第几天

    js获取当前日期为一年中的第几天 const currentYear = new Date().getFullYear().toString(); // 今天减今年的第一天(xxxx年01月01日) ...

  10. 【Amaple教程】6. 路由配置

    在 第1节<启动路由> 章节中为了能让单页应用顺利跑起来,我们提前介绍了简单的路由配置方法.我们已了解路由配置的目的是指定不同的url下对应的 模块节点(也叫做模块容器)内应该显示哪个模块 ...