HOWTO - Sashipa development

 Field: how to define default values.

You wish to define a value, that will be displayed by default in your cardForm in adding mode. And / or you wish to automatically record again a value on each update.

FkFields: static default values when adding mode

For FkFields, you can do this with an internationalValues list:

  <comboBoxFkField>
    <schemaFkRef .... />
    <defaultInternationalValueList>
      <internationalValue>1</internationalValue>
    </defaultInternationalValueList>
  </comboBoxFkField>

The number of internationalValues must match to the number of foreign key columns. Here there is one column in the foreign key. And the default value is the row that has the primary key value '1'. Remark: the default value is a primary key value, and not a label.

Simple fields: static default values when adding mode

For simple fields (ie. a field that works on one column), it's with a single internationalValue:

  <textField>
    <schemaColumnRef .... />
    <defaultInternationalValue>My default value</defaultInternationalValue>
  </textField>

This example works with a text column. Note that the value must have an international syntax (numbers with no comma or spaces, date format YYYY-MM-DD, date time format YYYY-MM-DD HH:MM:SS, boolean values are Y and N).

Simple fields: predefined default values for adding mode

Available predefined values are: currentDateTime, currentDate.

  <cardForm db='dbContact'>
    <!-- ... -->

    <fieldContainer>
      <textField readOnly='no' save='yes'>
        <schemaColumnRef schemaColumn='tblContact_Insertdate' />
        <defaultPredefinedValue data='currentDate' />
      </textField>
    </fieldContainer>
  </cardForm>

Remarks:

Simple fields: predefined value recorded on insert and each update.

Available predefined values are: currentDateTime, currentDate.

Here is the code:

  <cardForm db='dbContact'>
    <!-- ... -->

    <fieldContainer>
      <textField readOnly='yes' save='no'>
        <schemaColumnRef schemaColumn='tblContact_Lastupdatedate' />
        <defaultPredefinedValue data='currentDateTime' />
      </textField>
    </fieldContainer>

    <hiddenSchemaValueSet>
      <hiddenSchemaValue schemaColumn='tblContact_Lastupdatedate' data='currentDateTime' />
    </hiddenSchemaValueSet>
  </cardForm>

Remarks :

Simple fields: selected default values for adding mode

It's possible to define a select query, that will be executed each time the screen is opened in adding mode. The query must return a single row. The returned value will be displayed in the field when the cardForm will be in adding mode. The query is defined in a defaultSelectedValue element:

  <textField>
    <schemaColumnRef .... />
    <defaultSelectedValue>
      <selectQueryBuilder> ... </selectQueryBuilder>
    </defaultSelectedValue>
  </textField>

For an example of query, please go to the HOWTO on selected values. For details about selectQueryBuilder, you can go to here.

© 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.