jsonextjsnestedsubmitformpanel

How to convert nested json data into java object when form panel submit?


I'm trying to submit a form to server side using extjs 4.2.2 and jersey.

The problem I met is that I want to convert the json data to java object automatically, it can handle primitive data correctly, but for nested object it failed.

for example:

   class Foo {
       private String str;
       private Bar bar;
       getter/setter
   }

   class Bar {
       private String ss;
       getter/setter
   }

The form has two fields: str (Foo's), ss (Bar's), how can I make ext form panel convert field ss to Bar object when server side gets form json data?

Please help, thank you!


Solution

  • I got one solution which makes change on server side, just create a constructor for Bar, like

    public Bar(String ss) {
        this.ss = ss
    }
    

    Then the Bar object can be instantiated automatically.

    Are there any other solutions? Thank you