Announcement

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

    Setting DataSource POJO dataSourceField (SmartGWTPro2.2)

    Simplistic Setup:

    D1.ds.xml is a datasource for BO1 and D2.ds.xml is a datasource for BO2:-

    Code:
    class test.BO1
    {
       long id;
       String name;
       BO2 item;
    }
    Code:
    <DataSource ID="D1" serverType="generic">
      <fields>
        <field name="primaryKey" type="id" hidden="true" primaryKey="true" />
        <field name="item" type="D2" javaClass="test.BO2" displayField="name" editorType="select" optionDataSource="D2"/>
      </fields>
      <serverObject lookupStyle="new" className="test.server.BO1DMI" />
    </DataSource>
    and

    Code:
    class test.BO2
    {
        long id;
        String name;
     }
    Code:
    <DataSource ID="D2" serverType="generic">
      <fields>
        <field name="primaryKey" type="id" hidden="true" primaryKey="true" />
        <field name="name" type="text"/>
      </fields>
      <serverObject lookupStyle="new" className="test.server.BO2DMI" />
    </DataSource>
    I would like to set up D1 so that BO2's can be selected from a dropdown.
    The objective is to assign a BO2 to BO1.item by selecting it from a drop down. This doesn't seem to work. I thought perhaps there's a special way of using valueField to point to all of selected BO2 record instead of a field within it.

    In other words, it there a way that SmartGWT can auto populate BO1.item with selected BO2 on the serverside automatically. If not, is there a better way.


    Thanks.

    #2
    What you'll get submitted to the server is the ID - the other values from the object generally would not (and should not) be loaded. Your POJO could have a setter that takes the ID and populates a field of type object.

    Automatically doing is a behavior we've considered adding before, so if this will come up a lot, consider sponsoring having the generic behavior added.

    Comment

    Working...
    X