HOWTO - Sashipa development
You wish to replace your textField by a list of choices.
Two simple fields - based on a single SQL column - allow you to propose choices to user. These choices aren't values for foreign keys. You can define choices with a query or with a hardcoded list.
The two simple fields are the comboBoxSimpleField and the writeChoiceSimpleField. They have the same attributes and child-elements. Here is an example:
<comboBoxSimpleField onlySuggestedValues='no'>
<schemaColumnRef schemaColumn='tblDrink_Producer' />
... data: a query or a hardcoded list ...
</comboBoxSimpleField>
|
The attribute onlySuggestedValues specifies if user will be able to write its own value or if it will have to choose one of the proposed choices.
Now we can see how to define choices.
We wish to compute our choice. It can be done with a selectQueryBuilder. For example, we can propose to user the existing values already written in this field.
<comboBoxSimpleField onlySuggestedValues='no'>
<schemaColumnRef schemaColumn='tblDrink_Producer' />
<selectQueryBuilder distinctRequired='yes'>
<castFilterSet filterSensitive='no' />
<selectStatementBuilder autoPrimaryKey='no'>
<instanceColumnList>
<instanceColumn schemaColumn='tblDrink_Producer' />
</instanceColumnList>
</selectStatementBuilder>
<fromStatementBuilder>
<mainInstanceTable schemaTable='tblDrink' />
</fromStatementBuilder>
</selectQueryBuilder>
</comboBoxSimpleField>
|
You can obviously define the query you wish.
Remarks on this example: the query has type='list'. So it contains by default primary key columns. We remove this behaviour (autoPrimaryKey='no'). The query result will be agregated (distinctRequired='yes'). The query will ignore filters (filterSensitive='no') otherwise only the current choice will be returned.
In this situation, we allow user to add new values. Otherwise the software couldn't be used from an empty database.
They are defined like this:
<comboBoxSimpleField onlySuggestedValues='yes'>
<schemaColumnRef schemaColumn='tblDrink_Producer' />
<hardcodedRows>
<internationalValue>Value 1</internationalValue>
<internationalValue>Value 2</internationalValue>
<internationalValue>Value 3</internationalValue>
</hardcodedRows>
</comboBoxSimpleField>
|
This example will force the user to choose one of the three values. Don't forget that you will have to rebuild the application for changing theses values...
© Copyright 2003 Sashipa-Melba Team. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License as much as this note clearly appears.