Oaf traversing rows through the iterator standard

Source: Internet
Author: User

These two days I received a customer-reflected Bug:oaf purchase order page, after the addition of more than 10 lines submitted, there will be a null pointer exception. Originally, the default display line number of OAF is 10 lines, more than 10 lines, the page will be paginated. A null pointer exception is due to a row that has not been paged. The previous code (a method in AM), I wrote this:

        Zreqlinesvoimpl Zreqvo = THIS.GETZREQLINESVO (); int rowCount = Zreqvo.getrowcount (); Oaexception rowexception = Null;for ( int i = 0; i < RowCount; i++) {Zreqlinesvorowimpl Vendorrow = (Zreqlinesvorowimpl) zreqvo.getrowatrangeindex (i); if (vendorrow.getcate1 ()! = null&& vendorrow.getvendorname () = = null)//prompt when level one or two is not empty and the vendor name is empty. {                            ...                         }                 }

As you can see, the vendorrow of line fifth is created by Vo, which is where the problem lies. For some reason, the vendorrow created by VO can only fetch the row of the current page, and the row of the page cannot be taken.

Solution:

  at the time of my helpless, a functional consultant told me that there are similar codes in the system, which can be referenced. So I looked at the code based on the page he was looking for. It turns out that the standard traversal lines are traversed by creating a iterator, which can be found in the blog:http://blog.csdn.net/vslkyjnew/article/details/4552317 . The code is then modified as follows:

         Import oracle.jbo.rowsetiterator;//first to lead the package, or error! The method is implemented as follows: Zreqlinesvoimpl Zreqvo = THIS.GETZREQLINESVO (); oaexception rowexception = Null;int Fetchedrowcount = Zre Qvo.getfetchedrowcount (); Rowsetiterator iter = Zreqvo.createrowsetiterator ("iter");//create iterator for traversing int l_setrangestart = Iter.getrangestart ( int l_setrangesize = Iter.getrangesize (); int l_noemptyrowcount = 0;if (Fetchedrowcount > 0) {iter.setrangestart (0) ; Iter.setrangesize (Fetchedrowcount); for (int i = 0; i < Fetchedrowcount; i++) {Zreqlinesvorowimpl Vendorrow = (ZReqLine Svorowimpl) Iter.getrowatrangeindex (i); if (vendorrow.getcate1 ()! = null&& Vendorrow.getvendorname () = = null)/ /when level one or two is not empty, the vendor name is empty when prompted. {//When filling level one or two, the supplier is required. Please enter the supplier for line i+1. Iter.setrangestart (L_setrangestart); iter.setrangesize (l_setrangesize); Iter.closerowsetiterator ();// Close iterator immediately before throwing an exception, otherwise class naming conflict exception rowexception = new Oaexception ("\u5f53\u586b\u5199\u 4e00\u4e8c\u7ea7\u65f6\uff0c\u4f9b\u5e94\u5546\u4e3a\u5fc5\u586b\u9879\u3002 "+" \U8BF7\U8F93\U5165\U7B2C "+ (i + 1) +" \u884c\u7684\u4f9b\u5e94\u5546\ U3002 ", oaexception.information); throw rowexception;} if (vendorrow.getvendorname () = null)//When the vendor name is not empty, determine if the value being filled is a vendor {...) that exists in the database. Iter.setrangestart (L_setrangestart); iter.setrangesize (l_setrangesize); Iter.closerowsetiterator ();// Close iterator before throwing exceptions, or class naming conflict exceptions will occur rowexception = new Oaexception ("\U586B\U5199\U7B2C" + (i + 1) + "\u884c\u4f9b\u5e94\u5546 \u9519\u8bef\uff0c\u8bf7\u4fee\u6539 ", oaexception.information); throw rowexception;}}} Finally initialize and close the Iteratoriter.setrangestart (L_setrangestart);//need to study iter.setrangesize (l_setrangesize);// Need to study the next Iter.closerowsetiterator ();}

Summary: This modification bug let me learn a lot, about oaf iterator still have to continue to study.

Oaf traversing rows through the iterator standard

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.