【问题标题】:DynamicForm with ComboBoxItem and multiple DataSource具有 ComboBoxItem 和多个 DataSource 的 DynamicForm
【发布时间】:2013-08-09 10:21:47
【问题描述】:

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

【问题讨论】:

    标签: smartgwt smartclient


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2019-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-27
      • 2021-01-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多