ADF(UI)--<af:table>数据的延迟加载(二)

本文介绍了一种针对AF:Table组件数据加载慢的问题优化方案。通过预先执行VO的executeEmptyRowSet()方法,实现初始页面加载时不显示任何数据行,仅在用户输入过滤条件并点击查询时才加载数据,从而提高SQL执行效率。

针对页面<af:table>组件数据的延迟加载,除设置table的contentDelivery="lazy"属性,还可以在数据层面控制。

同样,在实际应用中,table对应的数据默认不带任何条件查询的SQL执行比较慢,而且结果集很大,尤其时需要排序的情况下,对大结果集数据的SQL执行效率更差,导致页面加载时间很长。即使设置contentDelivery="lazy"属性,也没有太大帮助,因为这还是需要加载数据。同时大结果集对用户来说没有什么实际意义。用户总不可能对上万甚至几十万条记录去逐一找自己想要的数据行吧。这情况下,适合一开始就不显示任何数据行,当用户输入过滤条件,点击查询时才开始查询数据。因为有过滤条件,可能返回的结果集就很少,而且SQL还可能走索引,因此SQL的执行效率会相当高很多。那么ADF的table,使用VO绑定时可以通过下面方式实现这效果。


实现的方法也很简单,就是在展示包含table的页面前是先执行table对应的VO的executeEmptyRowSet()方法。

实现具体步骤:

1、在table对应的VO里生成一个VO的具体实现类,在类里添加一个noResultSearch()方法,在里面添加一句:

this.executeEmptyRowSet();

如下图:


2、为在页面显示之前执行这个方法,简单的做法就是使用一个有界的taskflow,先把这个方法拖拽到taskflow上进行调用,如下图:

3、新建好显示table的页面,效果运行如下:

EVENT-2-1-29-v18.06 BASIC NOTIFICATION INTERFACE - MESSAGE CONTENT FILTER STEP 1 - Get Device service address StepStart: 2025-12-01T06:40:22.3377986Z http://192.168.137.183:2020/onvif/device_service STEP PASSED STEP 2 - Check that the DUT returned Device service address StepStart: 2025-12-01T06:40:22.3390947Z STEP PASSED STEP 3 - Get Services StepStart: 2025-12-01T06:40:22.3487002Z Transmit done Receive done STEP PASSED STEP 4 - Get Event service address StepStart: 2025-12-01T06:40:22.4627205Z http://192.168.137.183:2020/onvif/service STEP PASSED STEP 5 - Check that the DUT returned Event service address StepStart: 2025-12-01T06:40:22.4639577Z STEP PASSED STEP 6 - Get Event Properties StepStart: 2025-12-01T06:40:22.4677412Z Transmit done Receive done STEP PASSED STEP 7 - Check the DUT returned at least one MessageContentFilterDialect item StepStart: 2025-12-01T06:40:22.5542045Z STEP PASSED STEP 8 - Parse topic StepStart: 2025-12-01T06:40:22.5552156Z STEP PASSED STEP 9 - Creating listening server StepStart: 2025-12-01T06:40:22.5563346Z STEP PASSED STEP 10 - Send Subscribe request StepStart: 2025-12-01T06:40:22.5634503Z Transmit done Receive done STEP PASSED STEP 11 - Check that the DUT returned Subscribe response StepStart: 2025-12-01T06:40:22.6887225Z STEP PASSED STEP 12 - Check that CurrentTime is specified StepStart: 2025-12-01T06:40:22.6899326Z STEP PASSED STEP 13 - Check that TerminationTime is specified StepStart: 2025-12-01T06:40:22.691115Z STEP PASSED STEP 14 - Check that TerminationTime and CurrentTime has reasonable values StepStart: 2025-12-01T06:40:22.7033305Z STEP PASSED STEP 15 - Validate CurrentTime and TerminationTime StepStart: 2025-12-01T06:40:22.7053788Z STEP PASSED STEP 16 - Check if the DUT returned SubscriptionReference StepStart: 2025-12-01T06:40:22.7072632Z STEP PASSED STEP 17 - Check if SubscriptionReference contains address StepStart: 2025-12-01T06:40:22.7092127Z STEP PASSED STEP 18 - Check that URL specified is valid StepStart: 2025-12-01T06:40:22.7111144Z STEP PASSED STEP 19 - Wait for notification StepStart: 2025-12-01T06:40:22.7131926Z No notification received! STEP FAILED STEP 20 - Send Unsubscribe request StepStart: 2025-12-01T06:40:23.7306999Z Transmit done Receive done STEP PASSED TEST FAILED POST /onvif/service HTTP/1.1 Host: 192.168.137.183:2020 Content-Type: application/soap+xml; charset=utf-8 Content-Length: 1785 <?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:Header> <a:Action s:mustUnderstand="1">http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeRequest</a:Action> <a:MessageID>urn:uuid:3ea1fa1d-85ad-4288-92ce-ef59f2e08adf</a:MessageID> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:Username>admin1</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">gaHjGCwMj003ykGldqR+xFmDjLg=</wsse:Password> <wsse:Nonce>nhhnSBjihwHqZEhAUs/47A==</wsse:Nonce> <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2025-12-01T06:40:22Z</wsu:Created> </wsse:UsernameToken> </Security> <a:To s:mustUnderstand="1">http://192.168.137.183:2020/onvif/service</a:To> </s:Header> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Subscribe xmlns="http://docs.oasis-open.org/wsn/b-2"> <ConsumerReference> <a:Address>http://192.168.137.1:8152/onvif_notify_server/</a:Address> </ConsumerReference> <Filter> <wsnt:TopicExpression Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tns1="http://www.onvif.org/ver10/topics">tns1:RuleEngine/CellMotionDetector/Motion</wsnt:TopicExpression> </Filter> <InitialTerminationTime>PT60S</InitialTerminationTime> </Subscribe> </s:Body> </s:Envelope> HTTP/1.1 200 OK Server: gSOAP/2.8 Content-Type: application/soap+xml; charset=utf-8 Content-Length: 2476 Connection: close <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:hikwsd="http://www.onvifext.com/onvif/ext/ver10/wsdl" xmlns:hikxsd="http://www.onvifext.com/onvif/ext/ver10/schema"> <SOAP-ENV:Header> <wsa5:MessageID>urn:uuid:3ea1fa1d-85ad-4288-92ce-ef59f2e08adf</wsa5:MessageID> <wsa5:ReplyTo SOAP-ENV:mustUnderstand="true"> <wsa5:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa5:Address> </wsa5:ReplyTo> <wsa5:To SOAP-ENV:mustUnderstand="true">http://192.168.137.183:2020/onvif/service</wsa5:To> <wsa5:Action SOAP-ENV:mustUnderstand="true">http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeResponse</wsa5:Action> </SOAP-ENV:Header> <SOAP-ENV:Body> <wsnt:SubscribeResponse> <wsnt:SubscriptionReference> <wsa5:Address>http://192.168.137.183:2020/event-1_2020</wsa5:Address> </wsnt:SubscriptionReference> <wsnt:CurrentTime>2025-12-01T06:40:21Z</wsnt:CurrentTime> <wsnt:TerminationTime>2025-12-01T06:41:21Z</wsnt:TerminationTime> </wsnt:SubscribeResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
最新发布
12-02
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值