这种方式经常被用来,在button中处理一些逻辑,做法是在detail 页面中加一个button,对应是jS执行调用invoke controller

Define a webService method in Apex and then call it using the AJAX Toolkit in a button.

For example, suppose you want to create a Mass Add Notes button on accounts:
  1. Define the Web service method in Apex by clicking Setup | Develop | Apex Classes, clicking New, and adding the following code into the body of your new class:
sforce.apex.execute(类,方法名,参数);
global class MassNoteInsert{

  WebService static Integer insertNotes(String iTitle,
String iBody,
Id[] iParentIds) {
Note[] notes = new Note[0];
iBody = String.escapeSingleQuotes(iBody);
for (Id iParentId : iParentIds) {
notes.add(new Note(parentId = iParentId,
title = iTitle, body = iBody));
}
insert notes; //Bulk Insert return notes.size();
} }

  

2.Then, click Setup | Customize | Accounts | Buttons and Links, and click New in the Custom Buttons and Links related list.

3.Name the button and assign it the following attributes:

  1. Display Type: Detail Page Button
  2. Behavior: Execute JavaScript
  3. Content Source: OnClick JavaScript
{!REQUIRESCRIPT("/soap/ajax/42.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/42.0/apex.js")} var idsToInsert= {!GETRECORDIDS( $ObjectType.Account )};
var noteTitle = prompt("Please enter the title of the note");
var noteBody = prompt("Please enter the body of the note"); if (idsToInsert.length) { // Now make a synchronous call to the Apex Web service
// method
var result = sforce.apex.execute(
"MassNoteInsert", // class
"insertNotes", // method
{iTitle : noteTitle, // method arguments
iBody: noteBody,
iParentIds: idsToInsert }); alert(result[0] + " notes inserted!"); //response
} else if (idsToInsert.length == 0) {
alert("Please select the accounts to which" +
" you would like to add notes.");
}

066_VFPage中Js Button与controller交互方式(一)的更多相关文章

  1. html中的 button,input-button, image, input-image的区别

    hmtl中 为了验证 form的 action提交属性, 是指 表单提交到的 页面, 可以是任意 性质的页面, 如:html页面, php页面, asp页面等都可以, 实际在测试的时候, 可以就写 提 ...

  2. unity中js脚本与c#脚本互相调用

    unity中js脚本与c#脚本互相调用   test1.js function OnGUI() { if(GUI.Button(Rect(25,25,100,30),"JS Call CS& ...

  3. PhoneGap或者Cordova框架下实现Html5中JS调用Android原生代码

    PhoneGap或者Cordova框架下实现Html5中JS调用Android原生代码 看看新闻网>看引擎>开源产品 0人收藏此文章, 发表于8小时前(2013-09-06 00:39) ...

  4. 控制器controller与指令中的link、controller中变量作用域的关系

    angjualrjs中的作用域与原生js中的函数嵌套原理一致,都是存在作用域的继承.若在子控制器(同样包括在指令中的link或是controllerding中定义变量,此时指令中必须未使用scope独 ...

  5. JSON(二)——JavaScript中js对象与JSON格式字符串的相互转换

    首先我们来看一下js中JSON格式的字符串 var JSONStr1 = "{\"name\" : \"张三\"}"; 注意以下的写法不是j ...

  6. WebView中JS调用Android Method 遇到的坑整理

    WebView是android中常用的一个组件,其作用是展示网页,并让网页和android app进行一些业务逻辑上的交互. 其坑无数,相信用过的都知道,一个一个来解决吧. 1.怎么互调: <! ...

  7. BootStrap中的button使用

    原文地址:http://www.phloxblog.in/bootstrap-buttons/#.U5xYso2fclm 站点中事件的触发往往依赖于button或者超链接.因此,button能够觉得是 ...

  8. C# winForm webBrowser页面中js调用winForm类方法(转)

      有时我们在winform项目中嵌入了网页,想通过html页面调用后台方法,如何实现呢?其实很简单,主要有三部:   1.在被调用方法类上加上[ComVisible(true)]标签,意思就是当前类 ...

  9. 如何在MFC界面开发中响应Button按钮的Down和Up事件

    通过尝试有两种方案可以解决这个问题,第一种方案是通过PreTranslateMessage函数在调度消息之前对消息类型进行筛选,第二种方案是重载CButton类,在重载后的类CForTestButto ...

  10. [原创]在Framelayout中放置button控件出现的覆盖问题

    android Framelayout(帧布局)是很常用的布局,主要用来处理需要多个view叠加显示的情况. 然而在使用中,我发现Framelayout中的Button控件,会挡住所有其他控件,而不论 ...

随机推荐

  1. Linux基础介绍

    Linux基础介绍 一.运维的本质 运维:运行维护应用程序 岗位需求:自动化运维.DBA.docker+K8s 运维的本质: 1.尽可能保证应用程序24小时不间断运行 2.尽可能保证数据的安全 3.尽 ...

  2. 【分析笔记】Linux I2C-Tools 使用踩坑笔记

    一.踩坑缘由 在调试 I2C 器件时,我一般习惯于使用 i2cdetect 工具来确认芯片是否有应答,通常有应答之后,就会开始着手移植或者编写对应的驱动程序,但是在调试 sgp41 传感器时却不灵了. ...

  3. 职场IT老手教你3步教你玩转可视化大屏设计,让领导眼前一亮!

    我是制造企业的IT中心的研发人员,平常工作就是配合业务部门出出报表,选型一些商业软件,并在内部负责实施运维.最近领导出去参观了一些数字化转型比较领先的工厂和制造企业,回来就甩给我几张图,问能不能我们也 ...

  4. CSP-J初赛知识点

    就要初赛了,知识点还没怎么看,今天花一个小时来整理一下,希望大家在初赛中有个好成绩## 计算机常识IT : Information Technology 信息技术代别         年代       ...

  5. 安装CUDA

    https://developer.nvidia.com/cuda-toolkit-archive 使用deb安装的话,有时会报错: dpkg: 处理软件包 nvidia-driver-450 (-- ...

  6. GIN--HOW POWERFUL GNN

    HOW POWERFUL ARE GRAPH NEURAL NETWORKS? 本文是 Jure Leskovec 又一力作,首先对图神经网络的原理做了深入检出.提纲挈领的叙述,然后从原理方面介绍了如 ...

  7. 题解 Trie 但是你要最小化它的节点数量

    名字瞎取的 Description 给定 \(n\) 个字符串 \(s\),可以对 \(s_i\) 的字符打乱,将这些字符串加入一个 trie 里面求节点数量最小值. \(n\le 16, \sum ...

  8. 关于php imagettftext 函数错误解决问题

    imagettftext 这个函数是给图片添加水印的,但是不知道为什么我用不起,直到在网上找到了答案: 是因为字体文件路径原因,相对路径可能我位置不对,该成绝对路径就没问题了! 把'Facon-2.t ...

  9. 代码随想录算法训练营day24 | leetcode 77. 组合

    基础知识 回溯法解决的问题都可以抽象为树形结构,集合的大小就构成了树的宽度,递归的深度构成的树的深度 void backtracking(参数) { if (终止条件) { 存放结果; return; ...

  10. 基于Docker部署Dubbo+Nacos服务

    一.说明 本文介绍基于 Docker 部署一套 Dubbo + Nacos 的微服务环境,并解决容器里的 IP 及端口的访问问题. 基于上文<基于jib-maven-plugin快速构建微服务d ...