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