rest - Oracle Apex 20 - 交互式报告中列上的 REST 源操作
问题描述
我正在尝试使用表格报告设置表单并仅使用 REST 源。
目前我有一个表单和交互式报告设置。它使用带有动态项目的休息源。IE:
http://source/asm/instances/:group
:group
然后可以从表单中搜索到哪里。
现在返回的列都是与用户相关的,但我希望能够通过 REST API 设置一项。所以假设我进入了一个组并得到以下结果:
group | name | surname | status
ABC | Dan | Murray | inactive
ABC | Mary | Swanson | active
REST Source 具有status
远程激活/停用工具的功能。IE
http://source/asm/instances/ABC/dan/activate
和
http://source/asm/instances/ABC/dan/deactivate
现在我需要将状态列修改为具有两个选项的列表形式,激活/停用。This is where the issue comes in. When either of the two items are selected, it needs to use the relevant REST source as posted above and post to the tool, meaning it will activate/deactivate on the fly. 我整个周末都在寻找和尝试,但我找不到办法做到这一点。
到目前为止,我最接近的是创建一个链接,但这只是将我路由到我不需要的 URL。
我真的希望有人能够在这里帮助我,因为我正在苦苦挣扎。
解决方案
也许我解决了你的问题,试试看。:)
版本
Oracle Application Express 20.2.0.00.20
解决方案
我想您知道如何设置REST 数据源 (DS)并使用从 de DS 获取的数据创建交互式报告,因此我将跳过这些步骤。
- 转到您的交互式报告定义并在设置下找到本地后处理并设置值:
- 类型:SQL 查询
- SQL查询:
select
/*leave all the columns fetched from the DS*/
--
-- Add this column
'<a class="rest-button-status" data-id="'||<PRIMARY-KEY>||'">Link</a>' BUTTON
from #APEX$SOURCE_DATA#
转到BUTTON列定义,在Security disable Escape special characters下。
添加一个新的隐藏项并将其命名为 P1_NEW。
运行应用程序,您应该会在最后一列中看到带有链接的交互式报告。
现在添加一个定义为的动态操作(随意命名):
- 向这个 DA 添加两个 True 动作:
- 第一 - 设定值
// copy paste code
$(this.triggeringElement).attr('data-id')
- 第二 - 执行服务器端代码 (PL/SQL)
编辑要提交的页面项目 - P1_NEW
-- code
DECLARE
l_clob CLOB;
-- I added a parameter PK
v_url VARCHAR2(2000) := 'http://xxxxx:8080/ords/xxxx/xxxxxx/test-apex/deactivate?PK=';
BEGIN
L_CLOB := APEX_WEB_SERVICE.MAKE_REST_REQUEST(
-- I added a parameter PK
p_url => v_url||:P1_NEW,
p_http_method => 'POST' -- or GET or other
);
END;
切换系统(激活/停用)取决于您,也许最好的解决方案是拥有一个端点,然后 DS 控制状态。
编辑 - 基于评论 以下是第二个 DA 的一些屏幕截图:
- 向 DA 添加另一个操作。
- 定义一个
Execute Server-side Code
或Execute PL/SQL Code
(操作的名称取决于您拥有的 Oracle APEX 版本)
推荐阅读
- ios - IOS Sign In with apple using swift crash on iPad only on apple review
- android - 如何解决包含模块 Gradle 6.x?
- reactjs - redux 状态更新时如何更新本地状态(react-redux)
- html - 我正在努力在 CSS 中制作线性动画
- ruby-on-rails - 运行 rake db 时出现未知的 Ruby 错误:创建我在运行最新版本操作系统的树莓派上
- c# - Try Catch 中的返回值与泛型
- python-3.x - 将现有 Python3 方法转换为使用多处理
- security - 谷歌将我的密码保存到我使用 gmail 注册的其他网站是否正常?
- group-by - ABAP 字符串模板 - 带有 GROUP BY 的嵌入式表达式
- axon - 轴突事件处理超时