带有ComboBoxItem和多个DataSource的DynamicForm

时间:2013-08-09 10:21:47

标签: smartgwt smartclient

我是SmartGwt的新手。我试图用ComboBoxItem创建一个DynamicForm,我想从数据库中的某些表设置组合框值。保存表单数据的DataSource是另一个。我该如何管理?

这是我的java代码:

// DataSource
DataSource arcDS = DataSource.get("automaticExportConfig");
// ComboboxItem set
cycleList = new ComboBoxItem("cycle");
cycleList.setOptionDataSource(arcDS);
cycleList.setOptionOperationId("comboBoxCycleList");
cycleList.setDisplayField("cycle");
cycleList.setValueField("cycle");
cycleList.setAutoFetchData(true);
cycleList.setFilterLocally(false);

.ds.xml文件:

<DataSource
  dbName="PostgreSQL"
  ID="automaticExportConfig"
  serverType="sql"
  tableName="automaticExportConfig"
  titleField="id"
>

<fields>
    <field name="id" type="sequence" sequenceName="automaticExportConfig_id_seq" hidden="true" primaryKey="true"/>
    <field name="cycle" type="text" title="Cycle"  />
    </fields>

 <operationBindings>
    <binding operationType="fetch" operationId="comboBoxCycleList" outputs="id">
        <customSQL>SELECT id FROM billingcycle</customSQL>
        <serverObject className="com.demo.server.AutomaticExportConfigDMI" methodName="getComboBoxCycleList"/>
    </binding>

</operationBindings>

<serverObject lookupStyle="new" className="com.demo.server.AutomaticExportConfigDMI"/>

DMI.java文件:

public DSResponse fetch(DSRequest dsRequest) throws Exception {
    log.info("procesing AutomaticExportConfig DMI fetch operation");
    DSResponse dsResponse = dsRequest.execute();
    System.out.println("data"+dsResponse.getData());
    return dsResponse;
}

public DSResponse getComboBoxCycleList(com.isomorphic.rpc.RPCManager manager, javax.servlet.http.HttpServletResponse response, DSRequest dsRequest) throws Exception {
    log.info("procesing AutomaticExportConfig DMI fetch operation");
    DSResponse dsResponse = dsRequest.execute();
    System.out.println("listdata"+dsResponse.getData());
    return dsResponse;
}

数据显示在控制台中,但不在ComboBox中。

1 个答案:

答案 0 :(得分:0)

首选使用<operationBindings>标记在您的DataSource中加入文件。这是一个例子:

<operationBindings>
            <operationBinding operationType="fetch">
                <tableClause>crm_objects,crm_kind</tableClause>
                <whereClause>crm_objects.crm_obj_kind = crm_kind.crm_kind_idnum AND ($defaultWhereClause)</whereClause>
            </operationBinding>
        </operationBindings>

我希望我已经回答了你的问题,因为它不够明确