eva/3 Application BuilderApplication WizardsOverview of the ExamplesCustomer ServiceAspects of Design 

Change of Field Values Depending on the TComboBox Selection

In the form customer orders in the register maps job order parts and workers the values of the other columns are set with the values from the data base as a function of the selection in the appropriate TComboBox in the first column.

For this in the TComboBox with a change the selection the Command CopyValue is implemented. This is specified in the properties ItemStateChangedMakro and ItemStateChangedMakroParameters.

This Command is converted by the class CopyValue, which implements the interface SystemCommand:

public class CopyValue implements SystemCommand {

...

    public Object action(Object[] args, Macro macro) {
        try {
            String tableName = (String) args[0];
            String columnName = (String) args[1];
            String filteredColumnName = (String) args[2];
            String filteredBeanName = (String) args[3];

            String targetTableElementName = (String) args[4];
            String targetColumnName = (String) args[5];

            SWindow window = EvaUtils.getActiveSWindow();
            ControlledBean filteredBean = (ControlledBean) window
                    .getObject(filteredBeanName);
            STableElement targetTableElement = (STableElement) window
                    .getObject(targetTableElementName);

            if (filteredBean != null) {
                String sql = "SELECT " + columnName + " FROM " + tableName
                        + " WHERE " + filteredColumnName + " = 
                        + filteredBean.getControlledValue().toString();
                QueryDescriptor queryDescriptor = DBUtils.getQueryDescriptor(
                        sql, false);
                HSRecordSet recordSet = new HSRecordSet(queryDescriptor);

                double result = 0;
                if (recordSet.next()) {
                    result = recordSet.getObject(1) != null ? ((Number) recordSet
                            .getObject(1)).doubleValue()
                            : 0;
                }

                targetTableElement.updateObject(new Double(result),
                        targetColumnName);
                targetTableElement.refresh();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;

    }

}

With job order parts the value of the not visible SFormattedField SV_2 is set, which works as filter for the STableElement job order parts.

With workers the value of the not visible SFormattedField SV_1 is set, which works as filter for the STableElement workers.

These serve in each case as TableSource for the SScrollTables in the register maps. Now the other columns from the data base are updated with the values.