代码包路径
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;
}
}
当出错时,不要再修改文本区内容。