0

我是 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 中。

4

1 回答 1

0

有一个偏好是使用<operationBindings>标签在你的数据源中加入一个文件。这是一个例子:

<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>

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

于 2014-03-17T15:23:57.963 回答