从自定义按钮调用 apex 方法 [英] Call a apex method from a custom button

查看:25
本文介绍了从自定义按钮调用 apex 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从自定义按钮调用 apex 方法

i want to call a apex method from a custom Button

我意识到我们可以通过两种方式实现

I realise we can achieve this 2 ways

  1. 调用一个 VF 页面,然后调用页面属性上的方法
    <apex:page standardController="Opportunity" extensions="oppExt" action="{!changeStatus}"/>

使用javascript调用webservices方法

use javascript to call the webservices method

我的问题是关于这种情况的最佳实践.

The question i have is on the which is best practice to it for this scenario.

谢谢

推荐答案

这取决于您的用例.API 支持 控制器和扩展JavaScript 远程处理JavaScript 与 Web 服务.这些方法都基于定义的标准;这真的取决于开发人员或开发团队.

It depends on your use case. The API supports both Controllers and Extensions and JavaScript Remoting or JavaScript with Web Services. These methods are all based on defined standards; it's really up to the developer or development team.

JavaScript 更适合显示较少数据量的界面,但通常对用户更友好.

JavaScript is more suited for interfaces that display smaller amounts of data, but it is generally more user friendly.

我推荐 AJAX 工具包 针对此任务的 JavaScript 远程处理.更适合单字段更新;JavaScript Remoting 更适合通过 JavaScript 访问 Apex 方法.但是,两者都可以实现相同的结果.

I'd recommend the AJAX Toolkit over JavaScript Remoting for this task. It's better suited for single field updates; JavaScript Remoting is better suited for accessing Apex methods through JavaScript. However, the same result can be accomplished with either.

这篇关于从自定义按钮调用 apex 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆