当前位置:网站首页>Oracle apex Ajax process + dy verification
Oracle apex Ajax process + dy verification
2022-07-02 07:04:00 【Virtuous time】
at present apex Back end verification of , That is, after user input , Click submit to trigger the verification with the back-end server , To enhance the user experience , You can put this step ahead , use js Event triggers backend verification , Take monitoring whether the user name is repeated as an example .
The demo environment is apex 20.2
establish Ajax process
DECLARE
l_count NUMBER := 0;
BEGIN
-- Name duplicate verification
IF :P5_1 IS NOT NULL THEN
SELECT COUNT(1)
INTO l_count
FROM 666 v
WHERE v.1 = :P5_1
AND ROWNUM = 1;
IF l_count > 0 THEN
htp.p(' Customer :' || :P5_1 || ' Already exists ');
ELSE
htp.p('success');
END IF;
END IF;
-- No. repeat verification
IF :P5_2 IS NOT NULL THEN
SELECT COUNT(1)
INTO l_count
FROM 666 v
WHERE v.2 = :P5_2
AND ROWNUM = 1;
IF l_count > 0 THEN
htp.p(' Saved number is :' || :P5_2|| ' The customer !');
ELSE
htp.p('success');
END IF;
END IF;
END;
First in process Directly establish proce, Then select the location ajax, Be careful pl/sql There must be a return value , hinder js You need to judge according to the return value .
Be careful :htp.p There will be a space or tab after printing ,js When judging, you need to consider the operation of removing spaces from strings . Or print directly in this place json It's fine too ( Participate in the Corrigendum at the end of the text )
Create dynamic operations on the corresponding form page items
js Event selection change (onchange) perhaps Lose focus (onblur), True operation as execution js Code
apex.server.process('ajax_validate_customer_repeat',// The name here is process The name of
{
pageItems: '#P5_PARTY_NAME'// Pay attention to take # Number
}
,
{
dataType: 'text', success: function (data) {
if ( /*data*/ data.trim() != 'success') {
// use htp.p There is a space after the print , I don't know why , Notice here , It can also be used. apex Packaged api Print directly json
apex.message.clearErrors();
apex.message.showErrors([
{
type: "error",
location: ["page", "inline"],
pageItem: "P5_PARTY_NAME",
message: data,
unsafe: false
}/*, { type: "error", location: "page", message: data, unsafe: false }*/
]);
}
else
{
apex.message.clearErrors();
}
}
}
)
The effect is as follows
Follow up improvement
You can package the double check into a single js function
function repeat_validate(page_item_name) {
apex.server.process('ajax_validate_customer_repeat',
{
pageItems: "#" + page_item_name
}
,
{
dataType: 'text', success: function (data) {
if ( /*data*/ data.trim() != 'success') {
apex.message.clearErrors();
apex.message.showErrors([
{
type: "error",
location: ["page", "inline"],
pageItem: page_item_name,
message: data,
unsafe: false
}
]);
}
else {
apex.message.clearErrors();
}
}
}
)
}
Put the above paragraph js Put it in page 》JavaScript 》 Function and global variable declarations Go inside .
Then on the form item to be verified senior 》 customized : οnchange=“repeat_validate(‘P5_XXX’);”
In this way, public , There is no need to define dynamic operations on this page item .
Reference documents :
https://apex.oracle.com/pls/apex/germancommunities/apexcommunity/tipp/3341/index-en.html
https://www.foxinfotech.in/2020/04/oracle-apex-validation-without-submit-using-javascript-and-ajax-callback.html
Corrigendum
htp.p 、htp.print 、htp.prn The three are different :
HTP.p is a shortcut (undocumented) to htp.print. HTP. Print adds a new line to the output.
HTP. PRN does not add a line break.
htp.p and htp.print There will be one more automatically in the back /n New line
hpt.prn Not much /n
https://docs.oracle.com/database/121/ARPLS/w_htp.htm#ARPLS70586
边栏推荐
- Sublime text configuring PHP compilation environment
- PM2 simple use and daemon
- Cve-2015-1635 (ms15-034) Remote Code Execution Vulnerability recurrence
- Stress test modification solution
- Oracle rman自动恢复脚本(生产数据向测试迁移)
- Sqli Labs clearance summary - page 2
- Thinkphp5中一个字段对应多个模糊查询
- DNS攻击详解
- php中删除指定文件夹下的内容
- JS countdown case
猜你喜欢
SQLI-LABS通關(less6-less14)
Date time API details
SQL注入闭合判断
How to call WebService in PHP development environment?
Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance
Sqli-labs customs clearance (less18-less20)
Stack (linear structure)
The use of regular expressions in JS
In depth study of JVM bottom layer (V): class loading mechanism
PHP Session原理简析
随机推荐
TCP攻击
Sqli-labs customs clearance (less2-less5)
oracle-外币记账时总账余额表gl_balance变化(上)
CSRF攻击
JS create a custom JSON array
Take you to master the formatter of visual studio code
php中在二维数组中根据值返回对应的键值
pm2简单使用和守护进程
Redis -- cache breakdown, penetration, avalanche
Latex error: the font size command \normalsize is not defined problem solved
Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance
Atcoder beginer contest 253 F - operations on a matrix / / tree array
Brief analysis of PHP session principle
Sqli - Labs Clearance (less6 - less14)
Ceaspectuss shipping company shipping artificial intelligence products, anytime, anywhere container inspection and reporting to achieve cloud yard, shipping company intelligent digital container contr
Cloud picture says | distributed transaction management DTM: the little helper behind "buy buy buy"
MySQL index
Oracle段顾问、怎么处理行链接行迁移、降低高水位
Sqli-labs customs clearance (less1)
在php的开发环境中如何调取WebService?