I am new at SmartGwt. I am trying to make a DynamicForm with ComboBoxItem and I want to set combo-box values from some table in database. The DataSource which holds the form data is a different one. How can I manage this?
Here is my java code:
// 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 file:
<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 file:
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;
}
Data is shown in the console, but not in the ComboBox.
there is a preference to make join a file in your DataSource using
<operationBindings>
tag. Here is an example:I hope that I have answered your question because it is not clear enough