Jpivot MDX编辑器语法错误多出一空行问题

本文深入探讨了 EditCtrlConverter 类中的 convert 方法,详细分析了其核心逻辑及异常处理机制,包括输入验证、格式解析与转换、属性设置等关键步骤,并特别关注了 MDX 字符串中 '/r' 的去除与后续处理过程。同时,文章阐述了方法在遇到非法访问、无方法名、无效方法调用或格式错误时的异常捕获与响应机制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代码包路径

com.tonbeller.wcf.convert

文件:EditCtrlConverter.java

 

public void convert(Formatter formatter, Map param, Map fileSource,
            Element element, Object bean) throws FormatException,
            IllegalAccessException, NoSuchMethodException,
            InvocationTargetException
    {

        // disabled = true? return
        if (TypedCtrl.isDisabled(element))
            return;

        String id = EditCtrl.getId(element);
        String[] inputValue = (String[]) param.get(id);

        // input available
        if (inputValue != null && inputValue.length > 0)
        {

            XoplonNS.removeAttribute(element, "error");

            // parse input
            String formatString = EditCtrl.getFormatString(element);
            try
            {

                checkRequired(formatter.getLocale(), element, inputValue[0]
                        .trim().length() == 0);

                String type = EditCtrl.getType(element);
                FormatHandler handler = formatter.getHandler(type);
                if (handler == null)
                    throw new FormatException("no handler found for type: "
                            + type);

                Object newValue = handler.parse(inputValue[0], formatString);
                String strValue = handler.format(newValue, formatString);
                EditCtrl.setValue(element, strValue);

                //以上红色背景部分,是将“/r”在MDX字符串中去除,而当进入catch后就没有处理,


                String model = EditCtrl.getModelReference(element);
                if (bean != null && model.length() > 0)
                {
                    PropertyUtils.setProperty(bean, model, newValue);
                }

            } catch (IllegalAccessException e)
            {
                logger.info("exception caught", e);
                XoplonNS.setAttribute(element, "error", e.getMessage());
//             XoplonNS.setAttribute(element, "value", inputValue[0]);

                throw e;
            } catch (NoSuchMethodException e)
            {
                logger.info("exception caught", e);
                XoplonNS.setAttribute(element, "error", e.getMessage());
//                XoplonNS.setAttribute(element, "value", inputValue[0]);

                throw e;
            } catch (InvocationTargetException e)
            {
                logger.info("exception caught", e);
                XoplonNS.setAttribute(element, "error", e.getMessage());
//                XoplonNS.setAttribute(element, "value", inputValue[0]);

                throw e;
            } catch (FormatException e)
            {
                logger.info("invalid user input: " + e.getMessage());
                XoplonNS.setAttribute(element, "error", e.getMessage());
//              XoplonNS.setAttribute(element, "value", inputValue[0]);

                throw e;
            }
        }

当出错时,不要再修改文本区内容。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值