How to set the sequence value while saving the record in OA Framework

This is a requirement where people are used to Oracle forms style generation of unique number.The unique identifier for the record is derived from a database sequence when user saves the record in an OAF page.Most of the OAF pages developed by me has the sequence automatically generated in the Create method of the EO when user navigates to the screen.

Drawback of that approach is if user navigates to the create t screen and doesn't click on apply button then the sequence value will elapse and wasted.To avoid this ,follow the approach below to  simulate the Forms Style Generation of the unique Number.

 

 

In your entity object EOImpl.java write the below code.

 

Previous Approach :

 

    public void create(AttributeList attributeList) {
        super.create(attributeList);
        OADBTransaction transaction = getOADBTransaction();
        Number seqNo = transaction.getSequenceValue("FWK_TBX_EMPLOYEES_S");
        setFileId(seqNo);
    }

 

New Approach : Write the code in the setter method in EO.

 

    public void setFileId(Number value) {
       if (value == null) {
       OADBTransaction transaction = getOADBTransaction();
       value = transaction.getSequenceValue("FWK_TBX_EMPLOYEES_S");
      }
        setAttributeInternal(FILEID, value);
    }

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值