Announcement

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

    Qs on migration to SmartGWT

    I've got an app that may migrate to SmartGWT. It uses standard GWT widgets, GWTP, Guice, Gin, MyBatis. Please let me check some assumptions and ask a few questions that I hope are not too trivial.

    1) It seems that gradual migration from GWT widgets to SmartGWT widgets is possible, but not recommended. For an app with 16 to 20 screens, should I start it over from scratch or migrate gradually?

    2) Is anyone using Guice with SmartGWT? (I've seen mention of Spring, but Guice is working pretty well for us so far and I'd like to keep it.)

    3) How about Gin? Does it have any role in a SmartGWT applications?

    4) And MyBatis? I don't see it supported. But is there any reason to keep it if we use the Pro version of SmartGWT?

    Many thanks!
    ,chris

    #2
    1) it depends. As the FAQ mentions, it doesn't make sense to randomly intermix GWT and SmartGWT components, but in certain limited cases it's OK. In most situations, it makes sense to go ahead and replace a complete screen at a time at least, since this does not take very long anyway.

    2, 3, 4) Take a look at the QuickStart Guide and focus on the capabilities of SQL DataSource and especially SQL Templating, mostly discussed in the Server Framework chapter. Your entire Gin/Guice/MyBatis stack, plus all servlets and other boilerplate logic, can be replaced with a very brief XML file, and not only will it no longer be necessary to hand-code SQL for CRUD operations, you will also be able to customize the generated SQL at fine granularity without losing the generated parts that you'd like to keep. This is radically more powerful, more flexible and simpler, so we'd recommend making the leap straight to this new paradigm.

    Comment


      #3
      1) Great answer. I was hoping for a "go for it!" or "you're crazy", but of course your answer actually makes sense. ... :)

      2, 3, 4) I've gotten deeper in my eval and understand what you mean. Setting things up with SQL DataSources looks like a very good option for us. We'd have to throw away quite a bit of code, but that should be a good thing(!) in the long run. So far, I've modified the built-in-ds sample project to point to our MySQL database and used the DS Generator to produce the ds.xml files. (kudos! That was very slick.)

      We have a lot of association tables for n:n relationships, though, and I'm not clear yet how to support these. Do we need to use the Batch DS Generator or can we hand-code the missing parts? -- We may not be able to justify the Enterprise Edition for this project. -- If hand-coding support for n:n is possible then how is it done?

      An example of what I'm trying to achieve... Say we have an n:n for Person:Address. I want to go to a Person's detail page and see all their Addresses. I want to add and remove Addresses from the Person detail page. The I want to be able to go to any Address page and see all the associated Persons, and add/remove Persons from the Address. Then, just to throw a wrench in the works, I want to see the city of the 'primary' address in the 'Users List' page.

      To solve the relationships in the Person detail page, I need to filter the Addresses by the Person's ID in the association table. I expect this is no big deal but I haven't got that far in the docs or my eval project yet. Am I on the right track? Do I need the Enterprise Edition for this? How much would the Enterprise Edition help?

      To add the city to the Persons list, I suppose I could make a DB view. But is there a more SmartClient kinda way to do it? If so, what license do I need? (Pro, Power, or Enterprise?)

      Of course I'd love to just get Enterprise and forget about it. But I'm not sure I can justify it, especially at this early stage of our project. We currently have 4 developers but that could easily grow to 10, or maybe even more. Eventually the project will likely be absorbed into a larger organization for maintenance and I don't want them to get slammed with a huge bill. So I'm trying to find the right balance of productivity and long-term licensing costs.

      thanks again!
      ,chris

      Comment


        #4
        You basically want to use the classic SQL representation of many-many, 3 tables: person, address, join table. One DataSource for each, then declare foreignKey fields from the person and address DataSources to the join DataSource.

        This sample shows a screen for drag and drop association between two DataSources. This just needs to be generalized slightly so that the "Project Team" is it's own DataSource, and that's your use case.

        The persistence operations to perform on drop are automatically determined from the DataSource relationships declared by the foreignKey attributes in the DataSources, although if necessary, you can provide a RecordDrop handler and cancel() the event to avoid the default behavior, then do your own persistence operations.

        The SQL Templating chapters discuss how to declare joins and there's a sample here.

        Comment


          #5
          After reading up on templating and studying the code examples, I'm having trouble getting a field from a second table to show in the grid in BuiltInDs.java (from built-in-ds project). The data sources are shown below. The grid is unchanged from the built-in-ds but the datasources are configured to use my database instead of the built in hsql db.

          <DataSource
          tableName="User"
          ID="User"
          serverType="sql"
          >
          <fields>
          <field name="id" primaryKey="true" type="sequence" hidden="true" />
          <field name="userName" title="username" length="32" type="text" required="true" />
          <field name="role" type="integer" required="true" foreignKey="Role.id"></field>

          <field tableName="Role" name="name" title="Role" type="text" />
          <operationBindings>
          <operationBinding operationType="fetch">
          <tableClause>User, Role</tableClause>
          <whereClause>User.role = Role.id AND ($defaultWhereClause)</whereClause>
          </operationBinding>
          </operationBindings>
          </fields>
          </DataSource>

          <DataSource
          tableName="Role"
          ID="Role"
          serverType="sql"
          >
          <fields>
          <field primaryKey="true" name="id" type="integer" />
          <field name="name" length="100" type="text" />
          </fields>
          </DataSource>

          I expected this setup to show the role name in the grid but it just comes up blank, even though the data is correct in the database.
          The generated select statement is…
          SELECT User.id, User.userName, User.role FROM User WHERE ('1'='1') LIMIT 0, 75
          but I would expect something like…
          SELECT User.id, User.userName, User.role, Role.name FROM User, Role WHERE User.id=1 AND Role.id=User.role LIMIT 0, 75

          Also, there might be a couple of errors in the getting started pdf for section "SQL Templating — Adding Fields". It uses a double equal "==" where it maybe should be single "=". And the <operationBinding …> maybe should be nested in a <operationBindings>.

          Comment


            #6
            Move <operationBindings> out of <fields>.

            Comment


              #7
              YES!!! Wow. That was staring me right in the face.
              Thanks!

              Comment

              Working...
              X