我们通常会在EO里面对某些数据进行验证,比如在邀请供应商注册的时候,ORACLE标准逻辑会验证被邀请的供应商是否已经存在。

其验证逻辑在

oracle.apps.pos.schema.server.SupplierRegEOImpl

    public void setSupplierName(String value)
{
SupplierRegEntityExpert supplierregentityexpert = getSupplierRegEntityExpert(getOADBTransaction());
if (!supplierregentityexpert.isSupplierValid(value, getSupplierRegId()))
{
throw new OAAttrValException(121, getEntityDef().getFullName(), getPrimaryKey(), "SupplierName", value, "POS", "POS_SUPPREG_EO_ERR1");
} else
{
setAttributeInternal(2, value);
return;
}
}

现由于客户觉得标准的异常提示不够明显,无法区分此供应商是已经正式存在的供应商,还是已经被其他人邀请过的供应商。

所以现决定在保存的时候根据输入的供应商名称进行逻辑判断。

经验证,逻辑判断不能写在processFormRequest中,会先执行EO中的验证。

不过可以写在processFormData中,因为processFormData中的方法是在POST阶段执行,所以不会触发EO中的验证。

新建客户化CO继承原有标准CO

public class CuxSuppRegisterSupplierCO extends SuppRegisterSupplierCO {

}

    public void processFormData(OAPageContext pageContext,OAWebBean webBean){
super.processFormData(pageContext, webBean);
String str1 = pageContext.getParameter("event");
if (("sendInvitation".equals(str1)) || ("SaveNContinueBtnEvent".equals(str1)))
{ OAViewObject SupplierRequestsVO = (OAViewObject)pageContext.getApplicationModule((OAWebBean)webBean.findChildRecursive("RegSupplierRN")).findViewObject("SupplierRequestsVO");
String SupplierName = pageContext.getParameter("SupplierName");
Number SupplierRegId = (Number)SupplierRequestsVO.first().getAttribute("SupplierRegId");
LogUtil.of("validSupplierName ",pageContext).print(pageContext);
validSupplierName(pageContext,webBean,SupplierName,SupplierRegId);
} }
    public void validSupplierName(OAPageContext pageContext,OAWebBean webBean, String SupplierName,Number SupplierRegId){
LogUtil.of("validSupplierName fangfa ",pageContext).print(pageContext);
OraclePreparedStatement oraclepreparedstatement = null;
OracleResultSet oracleresultset = null;
OAApplicationModule am = pageContext.getApplicationModule(webBean);
try{
oraclepreparedstatement = (OraclePreparedStatement)am.getOADBTransaction().createPreparedStatement(" select vendor_id \n" +
"from po_vendors \n" +
"where upper(vendor_name) = upper(:1)\n" +
"and (start_date_active < sysdate OR start_date_active is null) \n" +
"and (end_date_active > sysdate OR end_date_active is null) \n" +
"and rownum = 1", 1);
oraclepreparedstatement.setObject(1,SupplierName);
oracleresultset = (OracleResultSet)oraclepreparedstatement.executeQuery();
if(oracleresultset.next()){
throw new OAException("POS_SUPPREG_EO_ERR1",OAException.ERROR);
}
}
catch(Exception exception1)
{
throw OAException.wrapperException(exception1);
} try{
oraclepreparedstatement = (OraclePreparedStatement)am.getOADBTransaction().createPreparedStatement("SELECT hou.attribute18,\n" +
" papf.full_name\n" +
" FROM pos_supplier_registrations psr,\n" +
" hr_all_organization_units hou,\n" +
" fnd_user fu,\n" +
" per_all_people_f papf\n" +
" WHERE upper(psr.supplier_name) = upper(:1)\n" +
" AND psr.supplier_reg_id <> :2\n" +
" AND psr.registration_status NOT IN ('REJECTED',\n" +
" 'DRAFT',\n" +
" 'RIF_SUPPLIER')\n" +
" AND rownum = 1\n" +
" AND psr.created_by = fu.user_id(+)\n" +
" AND psr.ou_id = hou.organization_id\n" +
" AND fu.employee_id = papf.person_id(+)\n" +
" AND SYSDATE BETWEEN nvl(papf.effective_start_date,\n" +
" SYSDATE - 1) AND nvl(papf.effective_end_date,\n" +
" SYSDATE + 1)\n", 2);
oraclepreparedstatement.setObject(1,SupplierName);
oraclepreparedstatement.setObject(2,SupplierRegId);
oracleresultset = (OracleResultSet)oraclepreparedstatement.executeQuery();
if(oracleresultset.next()){
String OrgName = oracleresultset.getString(1);
String FullName = oracleresultset.getString(2);
MessageToken[] tokens = { new MessageToken("ORG_NAME", OrgName),
new MessageToken("FULL_NAME", FullName) };
OAException exceptionMessage = new OAException("CUX","CUX_SUPPLIER_HAS_BEEN_INVITED",tokens,OAException.ERROR,null);
throw exceptionMessage; //PS1.使用throw直接抛出异常,会导致页面上直接基于EO的字段的数据不会被保留,且不会抛出EO中的验证。
// pageContext.putDialogMessage(exceptionMessage); //PS2.使用putDialogMessage(),页面上的数据被保留,且执行EO中的验证并抛出。
}
}
catch(Exception exception1)
{
throw OAException.wrapperException(exception1);
} }

参考资料:

1.重新整理后的Oracle OAF学习笔记——5.应用构建基础之实现控制器

2.OAF—Row的状态

标准的EO验证提示错误不够完整,抛出自定义的异常。的更多相关文章

  1. oracle 抛出自定义错误(网上找的例子)

    CREATE OR REPALCE TRIGGER minimun_age_checkBEFORE INSERT ON employeeFOR EACH ROWBEGIN IF ADD_MONTHS( ...

  2. Spring验证的错误返回------BindingResult

    Spring验证的错误返回------BindingResult 参考资料:http://www.mkyong.com/spring-mvc/spring-mvc-form-errors-tag-ex ...

  3. jQuery validate运作流程以及重复提示错误问题

    一,运作流程 jQuery validate要想运作,首先要加载相应的js <script type="text/javascript" src="/js/clas ...

  4. MVC与Validate验证提示的样式修改

    MVC中使用Validate的验证,要修改错误提示样式一共有3处需要修改,否则就不太完美了: MVC中的Validate的验证机制只用在后台写一次,就可以完成前台和后台的完美验证,前台的验证主要是依靠 ...

  5. jquery.validate提示错误方法

    修改jquery.validate提示错误方法,将错误信息用弹出框提示 <script src="@Url.Content("~/Scripts/jquery.validat ...

  6. Springboot学习05-自定义错误页面完整分析

    Springboot学习06-自定义错误页面完整分析 前言 接着上一篇博客,继续分析Springboot错误页面问题 正文 1-自定义浏览器错误页面(只要将自己的错误页面放在指定的路径下即可) 1-1 ...

  7. 今天遇到一件开心事,在eclipse编写的代码在命令窗口中编译后无法运行,提示 “错误: 找不到或无法加载主类”

    java中带package和不带package的编译运行方式是不同的. 首先来了解一下package的概念:简单定义为,package是一个为了方便管理组织java文件的目录结构,并防止不同java文 ...

  8. mac 下 使用 java运行 class 文件 总是提示 “错误: 找不到或无法加载主类”的解决方法

    发现问题 切换到mac平台后,突然想写点程序运行在mac下,想到mac自带java,会方便好多.不过在这过程中遇到了麻烦: 总是提示 “错误: 找不到或无法加载主类” 工程结构 查了好久,终于找到原型 ...

  9. .NetCore使用FluentValidation实现友好验证提示

    Nuget包导入FluentValidation.AspNetCore 官方的用法是在services中添加如下来操作 services.AddMvc().AddFluentValidation(co ...

随机推荐

  1. Linux系统对IO端口和IO内存的管理

    引用:http://blog.csdn.net/ce123_zhouwei/article/details/7204458 一.I/O端口 端口(port)是接口电路中能被CPU直接访问的寄存器的地址 ...

  2. Android实践项目汇报总结(下)

    微博客户端的设计与实现(下) 第四章 系统详细功能实现 本应用实现了如下主要模块:程序启动模块.登录授权模块.主界面显示模块撰写发表微博模块.用户发布信息模块.软件设置模块. 4.1程序启动模块实现 ...

  3. ubuntu下桌面假死处理方法(非重启)

    一.背景 2018/05/22,就在这一天,进入ubuntu的桌面后随便点击任何位置均无法响应,此时又不想重启,遂出此文 二.解决方案 2.1 关掉Xorg进程 2.1.1按下ctrl+alt+F1进 ...

  4. linux内核启动参数解析及添加

    1.环境: ubuntu16.04 Linux jello 4.4.0-89-generic #112-Ubuntu SMP Mon Jul 31 19:38:41 UTC 2017 x86_64 x ...

  5. SxsTrace

    https://troubleshooter.xyz/wiki/fix-the-application-has-failed-to-start-because-the-side-by-side-con ...

  6. 【第一章】 第一个spring boot程序

    环境: jdk:1.8.0_73 maven:3.3.9 spring-boot:1.2.5.RELEASE(在pom.xml中指定了) 注意:关于spring-boot的支持, 最少使用jdk7(j ...

  7. 安卓开发 UI入门

    布局的类型 线性布局 LinearLayout ***  垂直显示 vertical 水平显示 horizontal 文本适应 wrap_content 填充父窗体 match_parent 权重 l ...

  8. java中集合格式及json格式的特点和转换

    作者原创:转载请注明出处 今天在写代码,遇到一个难点,由于要调用webservice接口,返回的为一个list集合内容,从webservice调用接口返回的为一个string的io流, 在调用接口的地 ...

  9. 机器学习-数据可视化神器matplotlib学习之路(一)

    直接上代码吧,说明写在备注就好了,这次主要学习一下基本的画图方法和常用的图例图标等 from matplotlib import pyplot as plt import numpy as np #这 ...

  10. python 判断字符串是否以数字结尾

    import re def end_num(string): #以一个数字结尾字符串 text = re.compile(r".*[0-9]$") if text.match(st ...