Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Custom SmartGWT FormItem

    I've created a SmartGWT custom FormItem (by creating a child class CustomTextItem which extends com.smartgwt.client.widgets.form.fields.TextItem class), then I added an instance of CustomTextItem to some DynamicForm:
    Code:
    ...
    DynamicForm form = new DynamicForm();
    form.setFields(new TextItem("text_field"), new CustomTextItem("custom_field"));
    ...
    Now my problem is that I can't get the value of my customized object using getValue() method of the dynamic form:

    Code:
    Object text_value = form.getValue("text_field"); <<< this is OK
    Object custom_value = form.getValue("custom_field"); <<< this always returns null
    The question is that where does form object retrieves its values on sumbittion or validation?
    I think I should override some TextItem class method or set some property in order to do this.
    Any idea?

    #2
    ehsankh,

    You need not override anything.

    If you don't set any value to the TextItem it returns null by default. It should happen for both TextItem and CustomTextItem.

    See if you have set some value for the TextItem and did not for CustomTextItem. Try typing in something and see if it works.

    Also, try getEnteredValue on CustomTextItem and see if it returns any value.

    Thanks.

    Comment


      #3
      I've entered value for both of fields, also getEnteredValue returns correct value. I've no problem with my CustomTextItem when I want to get value using created object, ie:

      Code:
      Object val = custom_field.getValue(); <<< this works nice
      my problem is only with my DynamicForm which can't get the correct value of CustomTextItem object:

      Code:
      Object val = form.getValue("custom_field"); <<< but this does NOT works & always return null, even when the value is entered in text box

      Comment

      Working...
      X