Question

I am not able to retrieve data from FramedPanel using Bindings and BaseModelData with 2 fields. Can anyone tell me what went wrong.. I have also tried with and Editor options but it doesn't bind the data at all to the UI..

Map<String, Object> map = new HashMap<String, Object>(); 
    BaseModelData baseModelData;
    FramedPanel formPanel;
    Bindings bindings;
    User user = new User();
public Widget getLoginForm(){
          TextField textField = new TextField();
          textField.setHeight(10);
          textField.addValidator(new EmptyValidator<String>());
          textField.setName("userId");

          PasswordField passwordField = new PasswordField();
          passwordField.setName("password");
          VBoxLayoutContainer boxLayoutContainer = new VBoxLayoutContainer(VBoxLayoutAlign.CENTER);

          boxLayoutContainer.add(new FieldLabel(textField,"User Id"));
          boxLayoutContainer.add(new FieldLabel(passwordField, "Password"));
          map.put("userId", "asd");
          map.put("password", "");

          formPanel = new FramedPanel();
          formPanel.add(boxLayoutContainer);

           bindings = new Bindings();
          bindings.addFieldBinding(new FieldBinding(textField,"userId"));
          bindings.addFieldBinding(new FieldBinding(passwordField,"password"));

          baseModelData = new BaseModelData();
          baseModelData.setProperties(map);

          bindings.bind(baseModelData);

          TextButton b = new TextButton("Login");
          b.addSelectHandler(new SelectHandler() {

            @Override
            public void onSelect(SelectEvent event) {
            Info.display("User Id : ", baseModelData.get("password").toString());

            }
        });
          formPanel.addButton(b);
}
Was it helpful?

Solution

You should use the GWT editor framework for data binding.

Take a look at this documentation from Sencha:

http://docs.sencha.com/gxt-guides/3/data/editors/Editors.html

Using the Bindings and BaseModelData class is old styled GXT. It is part from the legacy package and should help to migrate an existing project. If you start a new project with GXT 3, I suggest to use the GWT editor framework.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top