Announcement

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

    How to draw a screen depending on server data

    Hi there
    I'm new to Smart GWT. I'm busy with a POC to see if the product will work for us.
    I really battle to understand how I can draw a screen depending on server data.
    In a typical JSP page I would use server data (like lookup data from the database) to populate a combobox with static/local options.
    I would for example be able to use java.util.Calendar functionality to draw an HTML table very specifically (No, I do not want to use the calendar widget).

    The data source is great, but I do NOT want to make a server call whereas I could load the pick list upfront.

    And what about those cases where depending on server data, I would draw the screen totally different?

    I use version 2.4 of Smart GWT.
    See the attached sample code that cannot work because it cannot include the Calander class during compile time:
    Attached Files

    #2
    java.util.Calendar is not supported in GWT (nor SmartGWT) - frankly, it's an awful class. It's rumoured that it'll be ported, but you have to make do without it.

    You need to get your head around the fact that GWT is nothing like JSP... It is Java compiled into Javascript. You can use Calendar and friends, but only on your server code. My suggestion would be learn some basic GWT before diving into SmartGWT.

    Comment


      #3
      Thanks for the answer. Maybe I should rephrase the question (forgetting about the Calendar class).

      I want to display a SelectItem with options retrieved from a database lookup table. The database lookup table has 9 records. There are many other like this.

      Currently I use SelectItem's DataSource functionality to retrieve with from Hibernate/Database. It works well.
      But, this is insufficient - I could have loaded the SelectItem options as local items.
      I can't get an example of how to create local SelectItem options - apart from hardcoding them - which I would like to avoid.

      Is there any way, GWT or SmartGWT, allows data to be retrieved from the database before the code is compiled into JavaScript?

      Comment


        #4
        If you expect JSP-style, server-processing of screens/forms before they are sent to the client, you are looking at the wrong product. With SGWT, the server typically provides the entire application to the browser and then only data is exchanged.

        The compilation step into JS is done manually, not on demand. If you want to lock in your form selections at that time, hard-coding is correct. Otherwise, the optionDataSource is the right way to go.

        Comment


          #5
          And in that style you've made a trip to the server for your page, which probably then queried your table to load the data anyway, so I don't think I understand the goal... you want to load data from a table without having to query the table?

          If caching didn't get you what you were after (you do know you have caching options?), I suppose you could query your database and create your ('hardcoded') value maps from that at build time (though it seems like more trouble than it's worth IMO).

          Comment


            #6
            Thanks for the replies!

            I do get the message that this is not possible.

            Comment


              #7
              No, incorrect, it is possible. If you change your .html bootstrap to a .jsp file you can output data as a JavaScript variable and pick it up via JSNI in GWT. But this is not usually worth doing.

              Comment


                #8
                Thanks for the information.

                Comment

                Working...
                X