ADF EO知识

EO的生命周期:

了解EO的生命周期需要从EO的几种操作动作来理解;

创建entity row:状态为NEW

查找entity row:状态为UNMODIFIES

更新entity row:状态为MODIFIES

删除entity row:状态为DEADED

事务提交:DEAD



1 有一种场景,有时我们需要控制EO中某些属性是只读的:

a:首先通过row拿到entity

b:然后通过entity拿到属性

c:设置属性为只读状态:

       

          DepartmentImpl impl= (DepartmentImpl ) r.getEntity(0);
           EntityDefImpl entityDefImpl = impl.getDefinitionObject();

           String[] atts=impl.getAttributeNames();
           for(String att:atts){
               AttributeDefImpl attributeDefXm = entityDefImpl.getAttributeDefImpl(att);
               attributeDefXm.setUpdateableFlag(AttributeDef.UPDATEABLE);
           }

2 获取EO的状态:

public String getRowStatus(Row row) {
        if (row != null) {
            JobsViewRowImpl rwImpl = (JobsViewRowImpl)row;
            String rwStatus = translateStatusToString(rwImpl.getEntity(0).getEntityState());
            return rwStatus;   
        }
        return null;
    }

    private String translateStatusToString(byte b) {
        String ret = null;
        switch (b) {
        case Entity.STATUS_INITIALIZED:
            {
                ret = "Initialized";
                break;
            }
        case Entity.STATUS_MODIFIED:
            {
                ret = "Modified";
                break;
            }
        case Entity.STATUS_UNMODIFIED:
            {
                ret = "Unmodified";
                break;
            }
        case Entity.STATUS_NEW:
            {
                ret = "New";
                break;
            }
        }
        return ret;
    }  

3 EO中获取属性原始值方法:

a 公共的方法:

EntityImpl::getAttribute(attrIndex,EntityImpl.ORIGINAL_VERSION)
      b: 需要override的方法:

EntityImpl::getPostedAttribute(int index) 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值