066_VFPage中Js Button与controller交互方式(一)
这种方式经常被用来,在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:
- 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:
- Display Type: Detail Page Button
- Behavior: Execute JavaScript
- 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交互方式(一)的更多相关文章
- html中的 button,input-button, image, input-image的区别
hmtl中 为了验证 form的 action提交属性, 是指 表单提交到的 页面, 可以是任意 性质的页面, 如:html页面, php页面, asp页面等都可以, 实际在测试的时候, 可以就写 提 ...
- unity中js脚本与c#脚本互相调用
unity中js脚本与c#脚本互相调用 test1.js function OnGUI() { if(GUI.Button(Rect(25,25,100,30),"JS Call CS& ...
- PhoneGap或者Cordova框架下实现Html5中JS调用Android原生代码
PhoneGap或者Cordova框架下实现Html5中JS调用Android原生代码 看看新闻网>看引擎>开源产品 0人收藏此文章, 发表于8小时前(2013-09-06 00:39) ...
- 控制器controller与指令中的link、controller中变量作用域的关系
angjualrjs中的作用域与原生js中的函数嵌套原理一致,都是存在作用域的继承.若在子控制器(同样包括在指令中的link或是controllerding中定义变量,此时指令中必须未使用scope独 ...
- JSON(二)——JavaScript中js对象与JSON格式字符串的相互转换
首先我们来看一下js中JSON格式的字符串 var JSONStr1 = "{\"name\" : \"张三\"}"; 注意以下的写法不是j ...
- WebView中JS调用Android Method 遇到的坑整理
WebView是android中常用的一个组件,其作用是展示网页,并让网页和android app进行一些业务逻辑上的交互. 其坑无数,相信用过的都知道,一个一个来解决吧. 1.怎么互调: <! ...
- BootStrap中的button使用
原文地址:http://www.phloxblog.in/bootstrap-buttons/#.U5xYso2fclm 站点中事件的触发往往依赖于button或者超链接.因此,button能够觉得是 ...
- C# winForm webBrowser页面中js调用winForm类方法(转)
有时我们在winform项目中嵌入了网页,想通过html页面调用后台方法,如何实现呢?其实很简单,主要有三部: 1.在被调用方法类上加上[ComVisible(true)]标签,意思就是当前类 ...
- 如何在MFC界面开发中响应Button按钮的Down和Up事件
通过尝试有两种方案可以解决这个问题,第一种方案是通过PreTranslateMessage函数在调度消息之前对消息类型进行筛选,第二种方案是重载CButton类,在重载后的类CForTestButto ...
- [原创]在Framelayout中放置button控件出现的覆盖问题
android Framelayout(帧布局)是很常用的布局,主要用来处理需要多个view叠加显示的情况. 然而在使用中,我发现Framelayout中的Button控件,会挡住所有其他控件,而不论 ...
随机推荐
- 高并发环境下3种方式优化Tomcat性能
摘要:Tomcat作为最常用的Java Web服务器,随着并发量越来越高,Tomcat的性能会急剧下降,那有没有什么方法来优化Tomcat在高并发环境下的性能呢? 本文分享自华为云社区<[高并发 ...
- MySQL 合并查询union 查询出的行合并到一个表中
在合并查询中,尤其是二分类的情况,在查询结果是相同列名的时候可以考虑合并查询.先查询出行的结果,再使用union或者union all合并查询结果. 另外如果 union 和 order by 一起使 ...
- 常用的函数式接口_supplier接口-接口练习
常用的函数式接口_supplier接口 常用的函数式接口java.util.function.SuppLier<T>接口仅包含一个无参的方法:T get().用来获取一个泛型参数指定类型的 ...
- 定时调度插件------FluentScheduler
定时调度插件------FluentScheduler 源码地址 官网文档地址 使用说明 dll引用 文章使用的版本为5.5.1版本 使用GuGet搜索FluentScheduler即可找到 如果框架 ...
- Vue.js 前端项目在常见 Web 服务器上的部署配置
Web 服务器是一种用于存储,处理和传输Web内容的软件.它是一种特殊类型的服务器,具有处理 HTTP 请求并向浏览器返回 Web 页面和其他内容的能力.Web服务器支持多种编程语言,如 PHP,Ja ...
- 阿里百秀后台管理项目笔记 ---- Day02
来吧展示: step1: 动态获取用户头像信息 引入 jquery.js 文件 <script src="/static/assets/vendors/jquery/jquery.js ...
- JavaScript 评测代码运行速度
一.使用 performance.now() API 在 JavaScript 中,可以使用 performance.now() API 来评测代码的运行速度.该 API 返回当前页面的高精度时间戳, ...
- 【Spring】Bean注册注解
@Configuration 同@Component,将标注的类作为一个组件,区别是会使用Cglib动态代理,因此使用该注解的类不能是final的 与@Component的区别可见:Configura ...
- SpringBoot Test Junit 联用
需要导入SpringBoot test和junit的包 @RunWith(SpringRunner.class) @SpringBootTest(classes = PiYuApplication.c ...
- Vue17 手机表单数据
1)v-model.trim trim修饰符是去掉前后空格 2)type="number" v-model.number type="number":只能输入数 ...