Announcement

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

    Timing issues using ValuesManager and ShowIfCondition

    I have a few forms that are tied together via a ValuesManager. One of these forms has a RadioGroupItem that determines which of its fields should be visible.
    When I call valuesManager.editNewRecord(initialValues), the appropriate radio item is selected, but the fields for it are not visible. If I do anything within the form that causes a redraw, then the expected fields becomes visible.

    Here is the affected form


    The parent class does the following on initialization


    In either case the, the radio item is set to DD for the new record. Is there something I need to do to actually catch the values getting set on the form.
    It appears from what I'm observing editNewRecord(map) is equal to editNewRecord(); valuesManager.setValues(map);

    I was hoping that the prior would allow initial values to be set on the form without it causing a form level itemChangedHandler being called until the user actually edited values.

    some appropriate code snippets

    I want to use user edits to drive the enabled state of some buttons. However, I seem to have ended up with a form that does not render itself correctly, and when a redraw is caused and the form is correct, the itemChangedHandler is fired, and I end up with buttons in an undesirable state.

    Perhaps you can guide me as to how to use your api to achieve this behavior
    Last edited by jpappalardo; 24 Sep 2014, 09:29.

    #2
    Using SmartGWT 3.0 eval.

    I have exactly the same issue. Please advise?

    Comment


      #3
      We're not reproducing this issue on our end.

      Here's our test case, based on the code you attached. In this test case the "DD" based fields appear and the others do not (and if you modify the initial values passed to the valuesManager, the other fields show up instead).

      There must be something about your application structure that differs from this enough to introduce the problem.

      If you could create a standalone test case we can run on our end that demonstrates the issue, we'll get to the bottom of it for you!

      Thanks
      Isomorphic software

      Code:
      import com.google.gwt.core.client.EntryPoint;
      import com.smartgwt.client.types.Alignment;
      import com.smartgwt.client.widgets.form.DynamicForm;
      import com.smartgwt.client.widgets.form.FormItemIfFunction;
      import com.smartgwt.client.widgets.form.ValuesManager;
      import com.smartgwt.client.widgets.form.fields.FloatItem;
      import com.smartgwt.client.widgets.form.fields.FormItem;
      import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
      import com.smartgwt.client.widgets.form.fields.SpacerItem;
      import com.smartgwt.client.widgets.form.fields.TextItem;
      
      public class ValuesManagerIssue implements EntryPoint {
          
      
          @Override
          public void onModuleLoad() {
              
              ValuesManager vm = new ValuesManager();
              
              DynamicForm f = new Geodetic();
              
              vm.addMember(f);
              
              f.draw();
              f.editNewRecord(new HashMap() {{ put("geodeticType", "DD"); }});
              
              
          }
          
          
          public class Geodetic extends DynamicForm {
              public Geodetic() {
                  TextItem latitudeDD = new TextItem("latitudeDD", "Latitude (DD)");
      //            latitudeDD.setValidators(new RegExpValidator(RegexHelper.DD_LAT_REGEX));
                  latitudeDD.setValidateOnChange(true);
                  latitudeDD.setShowHintInField(true);
                  latitudeDD.setHint("[+-NS]DD.dd");
                  latitudeDD.setVisible(false);
                  latitudeDD.setShowIfCondition(new FormItemIfFunction() {
                      @Override
                      public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
                          String type = dynamicForm.getValuesManager().getValueAsString("geodeticType");
                          return type != null && type.equals("DD");
                      }
      
                  });
                  TextItem longitudeDD = new TextItem("longitudeDD", "Longitude");
      //            longitudeDD.setValidators(new RegExpValidator(RegexHelper.DD_LONG_REGEX));
                  longitudeDD.setValidateOnChange(true);
                  longitudeDD.setShowHintInField(true);
                  longitudeDD.setHint("[+-EW]DD.dd");
                  longitudeDD.setVisible(false);
                  longitudeDD.setShowIfCondition(new FormItemIfFunction() {
                      @Override
                      public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
                          String type = dynamicForm.getValuesManager().getValueAsString("geodeticType");
                          return type != null && type.equals("DD");
                      }
                  });
      
                  TextItem latitudeDM = new TextItem("latitudeDM", "Latitude (DM)");
      //            latitudeDM.setValidators(new RegExpValidator(RegexHelper.DM_LAT_REGEX));
                  latitudeDM.setValidateOnChange(true);
                  latitudeDM.setShowHintInField(true);
                  latitudeDM.setHint("[+-NS]DD[: ]MM.mm");
                  latitudeDM.setVisible(false);
                  latitudeDM.setShowIfCondition(new FormItemIfFunction() {
                      @Override
                      public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
                          String type = dynamicForm.getValuesManager().getValueAsString("geodeticType");
                          return type != null && type.equals("DM");
                      }
                  });
                  TextItem longitudeDM = new TextItem("longitudeDM", "Longitude");
      //            longitudeDM.setValidators(new RegExpValidator(RegexHelper.DM_LONG_REGEX));
                  longitudeDM.setValidateOnChange(true);
                  longitudeDM.setShowHintInField(true);
                  longitudeDM.setHint("[+-EW]DD[: ]MM.mm");
                  longitudeDM.setVisible(false);
                  longitudeDM.setShowIfCondition(new FormItemIfFunction() {
                      @Override
                      public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
                          String type = dynamicForm.getValuesManager().getValueAsString("geodeticType");
                          return type != null && type.equals("DM");
                      }
                  });
      
                  TextItem latitudeDMS = new TextItem("latitudeDMS", "Latitude (DMS)");
      //            latitudeDMS.setValidators(new RegExpValidator(RegexHelper.DMS_LAT_REGEX));
                  latitudeDMS.setValidateOnChange(true);
                  latitudeDMS.setShowHintInField(true);
                  latitudeDMS.setHint("[+-NS]DD[: ]MM[: ]SS.ss");
                  latitudeDMS.setVisible(false);
                  latitudeDMS.setShowIfCondition(new FormItemIfFunction() {
                      @Override
                      public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
                          String type = dynamicForm.getValuesManager().getValueAsString("geodeticType");
                          return type != null && type.equals("DMS");
                      }
                  });
                  TextItem longitudeDMS = new TextItem("longitudeDMS", "Longitude");
      //            longitudeDMS.setValidators(new RegExpValidator(RegexHelper.DMS_LONG_REGEX));
                  longitudeDMS.setValidateOnChange(true);
                  longitudeDMS.setShowHintInField(true);
                  longitudeDMS.setHint("[+-EW]DD[: ]MM[: ]SS.ss");
                  longitudeDMS.setVisible(false);
                  longitudeDMS.setVisible(false);
                  longitudeDMS.setShowIfCondition(new FormItemIfFunction() {
                      @Override
                      public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
                          String type = dynamicForm.getValuesManager().getValueAsString("geodeticType");
                          return type != null && type.equals("DMS");
                      }
                  });
      
                  RadioGroupItem geodeticType = new RadioGroupItem("geodeticType");
                  geodeticType.setValueMap("DD", "DM", "DMS");
                  geodeticType.setShowTitle(false);
                  geodeticType.setWrap(false);
                  geodeticType.setVertical(false);
                  geodeticType.setColSpan(2);
                  geodeticType.setAlign(Alignment.CENTER);
                  geodeticType.setRedrawOnChange(true);
      
                  FloatItem elevation = new FloatItem("elevation", "Elevation");
      
                  setItems(geodeticType, new SpacerItem(), latitudeDD, longitudeDD, latitudeDM, longitudeDM, latitudeDMS, longitudeDMS, elevation);
                  setAutoWidth();
              }
          }
      
      
      }

      Comment


        #4
        geodetic.setDefaultValue("DD") seems to have set me on the right path. I believe the issue has something to do with the fact that I override onInit() and make a DMI call, whose RPCCallback then calls vm.editNewRecord(initialValues).

        Comment

        Working...
        X