Announcement

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

    convert com.smartgwt.client.data.Record to POJO

    Hi All,
    I'm new to smartgwt, great framework.
    Is there a utility class to convert Record to POJO and vice versa ?
    I thought about writing one by myself but I'm unable to add the Java reflection classes.

    My server side is managed by spring and my RPC send/retrieve pojos and it would be nice if I will be able to automatically convert them into Record in order to populate my ui components.

    Thanks in advance
    Dekel

    #2
    Take a look at the QuickStart Guide chapter on the Server Framework. POJOs can be returned as the result of a DataSource operation. The fields you declare in your DataSource are then automatically extracted and appear as Record objects client-side.

    This also avoids the need to write "DTOs" to limit the data sent to the client, since the DataSource naturally limits output to just the fields you're using client-side.

    Comment


      #3
      Thanks for the reply.
      Yes, I saw the examples, I was looking a way to avoid the definition of the .ds.xml

      Btw, correct me if I'm wrong, I saw in the javadoc that it is possible to define Datasource and mapping fields via code.

      Dekel

      Comment


        #4
        I also find this post which looks promising:

        http://forums.smartclient.com/showthread.php?t=10850&highlight=pojo

        Comment


          #5
          You can have a one-liner .ds.xml file which causes field definitions to be derived on the fly from Java POJOs, SQL tables or other sources of metadata (see the QuickStart Guide chapter on the Server Framework, at the beginning) or you can dynamically create the XML and pass it to DataSource.fromXML().

          Comment


            #6
            I see,
            Is it possible to write all my <DataSource> in one .ds.xml file?

            Comment


              #7
              Not yet, although as of the ability for most DataSources to have fields auto-generated (hence much shorter) we plan on adding this. No ETA.

              Comment

              Working...
              X