creapage.net

HOWTO - Sashipa development

 How to make a listForm content dependent of a field.

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:

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.