[英]Allow Number object to be null in Tapestry BeanEditor
I have an object I'd like to edit via beaneditor. 我有一个要通过beaneditor编辑的对象。 One of the properties is of the Number
class. 属性之一是Number
类。
When I try to display the beaneditor, I get the following error: 当我尝试显示beaneditor时,出现以下错误:
Parameter 'translate' of component core/PropertyEditBlocks:numberfield is bound to null. 组件core / PropertyEditBlocks:numberfield的参数“ translate”绑定为null。 This parameter is not allowed to be null. 此参数不允许为空。
When I changed the variable type to Double
, everything worked fine. 当我将变量类型更改为Double
,一切正常。
Does it have anything to do with the fact that Number
is an abstract class and cannot be instantiated? 它与Number
是一个抽象类并且无法实例化有关系吗? In that case, should I provide some sort of a translator or something like that so it uses, Double
for example, when editing the value? 在这种情况下,我是否应该提供某种翻译器或类似的东西,以便在编辑值时使用Double
,例如Double
?
TextField 's require a translate
parameter. TextField需要一个translate
参数。 Tapestry has defaults registered for String, Integer, Long etc. Since tapestry can't find a org.apache.tapestry5.FieldTranslator
it's complaining. Tapestry已为String,Integer,Long等注册了默认值。由于挂毯找不到org.apache.tapestry5.FieldTranslator
因此在抱怨。
Solutions: 解决方案:
translate
parameter) 明确地将FieldTranslator传递给TextField(例如,设置translate
参数) FieldTranslator
for Number (this sounds crazy to me). 注册一个Number的FieldTranslator
(这对我来说听起来很疯狂)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.