HOWTO - Sashipa development
In a screen, you wish to make a listForm content, dependent of field contents.
In a Person card screen, we want to display the person list with the same name. In this way, user won't record double instances of the same person.
So we have to reproduce a researchForm behaviour from a field of a cardForm. Before to begin I recommand to read the SelectQueryBuilder HOWTO.
Now we can see the Sashipa code.
In the cardForm we just have to give a name to fields that will be used for researchs.
<cardForm db='dbDemo'>
<title>Person card</title>
<location x='10' y='10' />
<cardSchemaTableRef schemaTable='tblPerson' updateAfterInsert='no'
multipleInsert='yes' queries='sudi' />
<fieldContainer>
<textField name='fieldPersonName'>
<schemaColumnRef schemaColumn='tblPerson_Name' />
</textField>
...
|
In the same screen is added a listForm:
<listForm db='dbDemo' delete='no'
disabledWhenInsert='no' displayRowCount='no'>
<title>Persons with the same name</title>
<bounds x='10' y='350' w='610' h='180' />
<selectQueryBuilder>
<castFilterSet filterSensitive='no' />
<fromStatementBuilder>
<mainInstanceTable schemaTable='tblPerson' />
</fromStatementBuilder>
<whereStatementBuilder>
<criteriaBuilder mode='or' emptyAction='stuck'
defaultSubEmptyAction='stuck' >
<researchCriteria>
<castSchemaValue>
<instanceColumn schemaColumn='tblPerson_Name' />
</castSchemaValue>
<fieldRef field='fieldPersonName' />
</researchCriteria>
</criteriaBuilder>
</whereStatementBuilder>
</selectQueryBuilder>
<instanceColumnList>
<instanceColumn schemaColumn='tblPerson_Name' letterCount='20' />
<instanceColumn schemaColumn='tblPerson_Firstname' letterCount='20' />
</instanceColumnList>
...
</listForm>
|
Explications:
By default, when there is a cardForm in a screen, all other forms are disabled when the screen is opened in adding mode. Here we want to cancel this behaviour: disabledWhenInsert='no'.
The query ignores filters (filterSensitive='no'), otherwise the listForm will contain only the current Person card when opening in modification mode.
A researchCriteria element is added in the where statement. It will build a SQL criteria like (Person.Name LIKE '%XXX%') where XXX is the content of the fieldPersonName field. A SQL 'LIKE' is the default comparator for text columns.
This criteria makes the query stuck when the field is empty (emptyAction='stuck' defaultSubEmptyAction='stuck'). So if the field is empty then the listForm is emtpy.
Be carefull: named fields have to be declared before to be used in a researchCriteria. So the cardForm must appear before the listForm in the screen Sashipa code.
A field name is only available in the Sashipa code of the screen (or in the Sashipa code of the form). If your field name is declared in an external cardForm (referenced by a cardFormRef element), you can't use the field in a listForm.
© 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.