Announcement

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

    Adding "bean" reference causes SmartGWT to not work witn ds.xml file

    Hi,

    We're evaluating SmartGWT, and so far, so good, except for one (odd but critical) issue so far.

    We're trying to avoid using Spring for two reasons: 1) the SmartGWT FAQ recommends that we not use it and that it's generally unecessary and a waste and 2) we agree strongly with the idea of minimalist code to achieve required functionality.

    Also, we're tring to use Hibernate beans.

    So, if we have our ds.xml defined as follows, everything works fine (except for the fact that the code does not appear to be using the getters/setters in the bean definition, as it's not getthing there when we put breakpoints in the getters/setters nor is it executing our custom getter/setter business logic):


    <DataSource ID="workflow" serverType="hibernate" tableName="workflow">
    <fields>
    <field name="wk_id" type="integer" primaryKey="true"/>
    <field name="wk_name" type="text" length="255"/>
    </fields>
    </DataSource>


    So, to get the code to use our getters/setters in our bean, we added a refernece to the bean information as follows:

    <DataSource ID="workflow" serverType="hibernate" tableName="workflow">
    <fields>
    <field name="wk_id" type="integer" primaryKey="true"/>
    <field name="wk_name" type="text" length="255"/>
    <beanClassName>beanClassName=com.smartgwt.sample.shared.Workflow</beanClassName>
    </fields>
    </DataSource>

    We also tried this different syntax:

    <DataSource ID="workflow2" serverType="hibernate" tableName="workflow" beanClassName="com.smartgwt.sample.shared.Workflow">
    <fields>
    <field name="wk_id" type="integer" primaryKey="true"/>
    <field name="wk_name" type="text" length="255"/>
    </fields>
    </DataSource>


    We came up with these ideas by trying to follow the example described here: http://www.smartclient.com/smartgwtee/showcase/#master_detail_batch
    (This examples closely matches what we eventually intend to do, as we have a 1 to many relationship we need to model.)

    However, when we make reference to the bean and we run the code via GWT Debug Mode or GWT "Run as GWT Appication" , we get "Uncaught Exception" and it would appear that the code does NOT any longer bind to the datasource "Workflow". (In fact, it specially says that the datasource points to NULL.)

    It seems like the reference to the bean throws it off. We're 100% sure that the beanname is correct (including case sensitivity).

    Also, in case it helps, we essentially just modified the sample code "Built-In-DS". Further, although I don't think this is important, we're not using HSQLDB but instead using MySQL and that part seems to work just fine. Finally, in an effort to minimize code, we do not have any custom DMIs etc.

    So again, everything works if we omit the "bean" reference in the ds.xml file, except for the fact that it doesn't actually use our bean's getters/settters. If we put in the bean reference, then we get errors and it refuses to "see" (or maybe it's not parsing properly) the ds.xml file.

    This should be simple, and our goal is to follow the SmartGWT model of minimum code to achieve required funcitonality. So, we do NOT want to use Spring Framework etc (otherwise, we would have used some of the other samples that come with SmartGWT). From what we understand, this code above is the "right" way to do things....

    Final details:

    OS: Windows XP Pro (uptodate)
    IDE: MyEclipse 9.0 with Google Plugin for Eclipse (2.3.1) (These are all the latest software as of today).
    SmartGWT EE 2.4
    Broswer: Mozilla Firefox (4.0.1)
    GWT SDK: 2.2 (since GWT SDK 2.3 has issues with SmartGWT EE 2.4)
    Sun JDK 1.6.0_13

    Regards,
    Gautam

    #2
    The FAQ doesn't recommend against Spring (you may be thinking of GWT-RPC, which we do strongly recommend against).

    Your first sample is working as designed and as documented - in the absence of beanClassName, you're using beanless mode, no bean is required.

    In the second sample the beanClassName property is misplaced. There's no need to guess where it goes or try to copy samples, this and all other properties allowed in .ds.xml files are documented here.

    As far as the error you ended up with, you need to post the actual error rather than just refer to it ambiguously, but our guess would be that it doesn't have to do with beanClassName but just with mismatched IDs (we noticed that your .ds.xml definition now shows "workflow2"). The FAQ contains the list of all possible mistakes that can interfere with DataSource loading and how to fix them.

    Finally, the truly minimal code approach, and our first recommendation (see QuickStart Guide) is to use the SQLDataSource. Then, you do not even write a bean, and typical customizations such as multiple-table joins are much easier to achieve (no Java code, entirely declarative).

    Comment


      #3
      Thank you again for a prompt response. The "sqldatasource" worked perfectly. -Regards, Gautam

      Comment


        #4
        Regarding SQLDataSource being best/easiest for one-to-many db table relationships, are there any examples of this in either the documentation, sample code, or SmartGWT Showcases examples? The only references I found all pointed to this link:http://www.smartclient.com/smartgwtee/showcase/#master_detail_batch

        and that example strictly uses Hibernate as well as java beans, not SQLDataSource without declared java beans.

        Regards,
        Gautam

        Comment


          #5
          Everything under the Transactions folder, as well as "Large Value Map", "User-Specific Data" and "Dynamic Reporting" under the SQL folder all involve multiple tables in one-to-many relationships, doing joins, persisting to multiple tables in one transaction, etc.

          We don't really make it hard to find :) What you may not have noticed is that any time you see a <DataSource> that says serverType="sql", that means it's using the SQLDataSource.

          Comment

          Working...
          X