Announcement Announcement Module
Collapse
No announcement yet.
Problems with binding an object that contains other objects Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with binding an object that contains other objects

    Hi,

    I'm am having problems with binding an object that contains other objects, such as this:

    Code:
    class SomeData{
       String name;
       List servers;
    }
    
    class Server{
       String ipAddress;
       String port;
    }
    What I'm trying to do is have a panel listing all the information for the 'SomeData' object. eg)
    Name: someName

    Server1 IPAddress: 10.0.0.1 port: 123
    Server2 IPAddress: 10.0.0.2 port: 123
    Server3 IPAddress: 10.0.0.3 port: 123

    I used the SwingFormModel, passing in the SomeData object. When creating a form, I'm using a TableFormBuilder. The property name of the servers that I tried is 'server[0].ipAddress' , 'server[0].port', 'server[1].ipAddress', etc.. however, this does not seem to work.

    eg)

    Code:
        protected JComponent createFormControl() {
            TableFormBuilder formBuilder = new TableFormBuilder(getFormModel());
            formBuilder.add("name");
            formBuilder.row();
            formBuilder.add("servers[0].ipAddress");
            formBuilder.add("servers[0].port");
            formBuilder.row();
            formBuilder.add("servers[1].ipAddress");
            formBuilder.add("servers[1].port");
            formBuilder.row();
            formBuilder.add("servers[2].ipAddress");
            formBuilder.add("servers[2].port");
      
            return formBuilder.getForm();
        }

    What should be the property name for ip address and port for each of the server object?

    Does anyone have any suggestions on how to do binding with contained objects?


    Your help will be greatly appreciated. Thanks in advance.
Working...
X