【问题标题】:Custom SmartGWT FormItem自定义 SmartGWT 表单项
【发布时间】:2012-06-26 15:10:40
【问题描述】:

我创建了一个 SmartGWT 自定义 FormItem(通过创建一个扩展 com.smartgwt.client.widgets.form.fields.TextItem 类的子类 CustomTextItem),然后我向一些 DynamicForm 添加了一个 CustomTextItem 的实例:

...
DynamicForm form = new DynamicForm();
form.setFields(new TextItem("text_field"), new CustomTextItem("custom_field"));
...

现在我的问题是我无法使用动态表单的getValue() 方法获取自定义对象的值:

Object text_value = form.getValue("text_field"); <<< this is OK
Object custom_value = form.getValue("custom_field"); <<< this always returns null

问题是表单对象在哪里检索其提交或验证的值?
我想我应该重写一些 TextItem 类方法或设置一些属性才能做到这一点。
有什么想法吗?

【问题讨论】:

    标签: forms gwt customization smartgwt


    【解决方案1】:

    您需要覆盖CustomTextItem 中的getValue 方法并返回CustomTextItem 的值

    【讨论】:

    • @EhsanKhodarahmi 是的,确实如此,您只需要知道在其中放入什么即可。我不认为一个简单的super.getValue() 会解决它?
    • @EhsanKhodarahmi 至少向我们展示您的 CustomTextItem 的代码
    【解决方案2】:

    您可以像这样form.getItem("yourItemInstanceName").getValue() 直接从您的项目中获取值
    您不需要为此访问表单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-19
      • 1970-01-01
      • 1970-01-01
      • 2018-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多