OAF控制数据显示格式例如:数字显示样式999,999.99 [转]

import oracle.cabo.ui.validate.FoRMAtter;
import oracle.apps.fnd.framework.webui.OADecimalValidater;
import oracle.apps.fnd.framework.webui.beans.OAWebBeanDataAttribute;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;

processRequest中加入
    Formatter formatter = new OADecimalValidater("#,###,###,##0;(#,###,###,##0)", "#,###,###,##0;(#,###,###,##0)");
    OAMessageTextInputBean Fare = (OAMessageTextInputBean)webBean.findChildRecursive("Fare");
     if(Fare != null)
        Fare.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);
     ((OAWebBeanDataAttribute)tableBean.findIndexedChildRecursive("Fare")).setTabularFunctionCurrencyCode("CNY");
或者

 
这个方法其实只要设置了币种就可以了,当然,需要在首选项里设置数字格式,同时这也是一个Profile,可以在系统管理员配置。

例如:
    OAMessageStyledTextBean cost = (OAMessageStyledTextBean)webBean.findIndexedChildRecursive("Cost");
    cost.setAttributeValue(CURRENCY_CODE, "CNY");

做点补充:
    需要导入的类都位于:oracle.cabo.ui.validate
    Formater的子类有ColorValidater, WMLPatternValidater, ByteLengthValidater, DecimalValidater, DateValidater
    1、DateValidater:验证日期格式。不但可以用于“OAMessageDateFieldBean”,也可用于“OAMessageTextInputBean”。 例如:
        OADateValidater formatter = new OADateValidater("yyyyMMdd", "");
    2、WMLPatternValidater:验证文本框的格式。 例如:
        WMLPatternValidater formatter = new WMLPatternValidater("8N");
    3、ByteLengthValidater:验证入力的byte长度。 例如:
        ByteLengthValidater formatter = new ByteLengthValidater(10, "Windows-31J");
        当入力的字符中有全角,超出规定的byte数后,会报出客户端的错。与在画页面的时候,设置控件的长度效果一样。
    4、DecimalValidater:验证入力数字的大小。 例如:
        DecimalValidater formatter = new DecimalValidater();
        formatter.setMaxValue(10);
        formatter.setMinValue(2);
        (webBean.findChildRecursive("item1")).setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);
    5、若是需要自定义地、更复杂地属性验证,可以使用RegExpValidater。 例如:
        (webBean.findChildRecursive("item1")).setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, new RegExpValidater("[0-9]{3}"));
    6、以上的验证可以写在processRequest()方法的webBean的setAttributeValue()中,
       若在触发submit请求时,有验证错误的话,就会先在客户端弹出系统标准的javaScript的错误消息。
       同时,对于想在submit请求以后,再进行属性验证的时候,可以调用ValidationUtils.validate()方法。
       这个方法有三个参数,其中那个String的参数对应的值,是页面上控件的值。 例如:
        OAMessageTextInputBean dfb = (OAMessageTextInputBean)webBean.findChildRecursive("item1");
        java.text.ParseException[] p =
          ValidationUtils.validate(pageContext.getRenderingContext(), new WMLPatternValidater("8N"), (String)dfb.getValue(pageContext));
        if (p != null && p.length > 0)
        {
          throw new OAException("YOUR MESSAGE...");
        }
    7、其中OAF中继承的类有OADateValidater和OADecimalValidater。具体的使用方式,可以参照各个类的DOC。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值