Results 1 to 5 of 5

Thread: Binding Java object to XML Datasource GWT

  1. #1
    Join Date
    Jun 2009
    Posts
    56

    Binding Java object to XML Datasource GWT

    I need a little help on a java problem:

    In one sentence: I want to present the user with the structure of a java object, ie each field values (a toString () will do), and the possibility to browse complex types (lists, maps, etc..).

    roughly, the view "Variables" of Eclipse

    I have some technical limitations:
    JAVA objects (retrieved from a repository running on a jdk1.4)
    rendering done in a GUI GWT (jdk1.6)
    my items are quite complex and their structure is not known in advance

    I begin just my thoughts and at first sight, I am tempted to approach the problem from this angle:
    1) GWT likes the datasources in XML. So far I see GWT manipulate an XML describing the object that I must show (form name = attribute name, value = toString () attribute)
    2) I must then find a java lib allowing me to generate XML on the fly from a java object passed as parameter, by introspection attributes (or possibly use getters).

    Any idea?

  2. #2
    Join Date
    Feb 2008
    Posts
    1,856

    Re: Binding Java object to XML Datasource GWT

    xstream, but it only works on server side

  3. #3
    Join Date
    Jun 2009
    Posts
    56

    Re: Binding Java object to XML Datasource GWT

    The fact that it runs on the server side does not worry, the very opposite:

    The manipulation will require a call server side to retrieve the full Java object, so as to make as much as the Transco java-> xml is done server side.

    Thank you in any case.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Binding Java object to XML Datasource GWT

    XStream is not bad, I also used JAXB 2 (included in J2EE) and it works very well too.

  5. #5
    Join Date
    Jun 2009
    Posts
    56

    Re: Binding Java object to XML Datasource GWT

    OK, thank you, I started watching the side of XStream:

    Not bad actually, and it can easily highlight the directory structure of a java object as XML.

    Here, I encountered two limitations of GWT:

    1) XML input grid is not an XML "standard" (with n levels) nested XML but a "flat" for each subject with a foreign key to its parent object.

    Code:
    <List>
    −
    <employee>
      <EmployeeId>4</EmployeeId>
      <ReportsTo>1</ReportsTo>
      <Name>Charles Madigan</Name>
      <Job>Chief Operating Officer</Job>
      <Phone>x10962</Phone>
      <Email>cmadigan@server.com</Email>
      <OrgUnit>Management</OrgUnit>
      <Salary>26200.00</Salary>
      <Gender>male</Gender>
      <MaritalStatus>married</MaritalStatus>
      <EmployeeType>full time</EmployeeType>
      <EmployeeStatus>active</EmployeeStatus>
    </employee>
    −
    <employee>
      <EmployeeId>192</EmployeeId>
      <ReportsTo>4</ReportsTo>
      <Name>Ralph Brogan</Name>
      <Job>Mgr Software Client Supp</Job>
      <Phone>x32524</Phone>
      <Email>rbrogan@server.com</Email>
      <OrgUnit>Management</OrgUnit>
      <Salary>13700.00</Salary>
      <Gender>male</Gender>
      <MaritalStatus>married</MaritalStatus>
      <EmployeeType>full time</EmployeeType>
      <EmployeeStatus>active</EmployeeStatus>
    </employee>
    −
    <employee>
      <EmployeeId>295</EmployeeId>
      <ReportsTo>192</ReportsTo>
      <Name>Bhushan Sambhus</Name>
      <Job>Line Worker</Job>
      <Phone>x12125</Phone>
      <Email>bsambhus@server.com</Email>
      <OrgUnit>Management</OrgUnit>
      <Salary>8300.00</Salary>
      <Gender>female</Gender>
      <MaritalStatus>married</MaritalStatus>
      <EmployeeType>part time</EmployeeType>
      <EmployeeStatus>active</EmployeeStatus>
    </employee>
    </List>
    2) GWT expects that the fields are defined explicitly in order to render ... This is not my case, because the generated XML by XStream uses as a tag attribute names ...

    In short, I must find a way to convert the XML into an XML XStream "GWT compliant" ... and it is not won

Similar Threads

  1. get classes and object in java
    By preeti makkar in forum Software Development
    Replies: 1
    Last Post: 07-05-2012, 11:08 AM
  2. Adding an object in java
    By Gunner 1 in forum Software Development
    Replies: 5
    Last Post: 27-02-2010, 02:20 AM
  3. How big is an Object in Java? Why Java neglects sizeof?
    By KALINDA in forum Software Development
    Replies: 4
    Last Post: 10-11-2009, 02:19 AM
  4. How to create object in JAVA
    By HP_Crook in forum Software Development
    Replies: 3
    Last Post: 09-10-2009, 11:52 PM
  5. Object test = new Object() <-- Java, best way in C++
    By ADISH in forum Software Development
    Replies: 3
    Last Post: 25-10-2008, 02:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •