Re: Request for trigger recipes

"Adrian Maier" <[email protected]> Wed, 1 Nov 2006 12:21:45 +0200
Newsgroups gmane.comp.gnu.enterprise.general
Message-ID <[email protected]>
On 10/31/06, James Thompson <[email protected]> wrote:
> On Tuesday 31 October 2006 6:21, Adrian Maier wrote:
>
> http://www.gnuenterprise.org/~jamest/GNUe-Complete-Guide.pdf
>
> As you can see GNUe Forms is the section (starting about 16 pages in) is where
> I've been experimenting.  I think I've got most my OpenOffice.org issues
> figured out and was planning to do some part/chapter re-org next followed by
> a more complex master/detail example.  Instead, I'd be happy to document
> triggers and include some recipes.
>
> I'd appreciate any suggestions on topics to cover or tasks you'd like to see
> put into a recipe.

James,

As I've promised yesterday on irc , here are a few trigger recipe ideas for
the gnue-forms chapter  :

1) displaying some information  (   form.showMessage  )
2) basic manipulation of the fields'  values :   set and get . This could also
    demonstrate how to access a certain field  via   block_name.field_name .
    Possible gotchas when manipulating a field's value based on the type
    of the trigger (i don't know whether there are such situations).
3) using parameters and options
4) read a specific row from the database and do something with the values .
    This might not be specific to the gnue-forms,  but it's definitely useful
    in triggers.
5) execute a query and iterate over the rows.   Compute the average value
     based on those rows.
6) populate some fields when a new record is added , in different ways :
     with constants,   from parameters,  from another fields,  with some
     mathematical formula ,  or from a table.
7)  computing the value of a field based on other fields of the same record ,
    for example value = quantity*price ,  inside a Post-Change trigger
of the field.
8) validation that a value of a field meet certain criteria , like :
   -  the value is in a certain interval
   -  field1+field2+field3+field4 must equal 100
   There are different actions to do when the validation fails:
     (a) display a warning message (showMessage),  or
     (b) revert the field to null or some default value, or
     (c) cancel the update .... is this possible at all ?
9) look-up dialogs.  The user would press a button,   the clients are displayed,
    the user selects one of the clients and finally some fields
(client_code and
    client_name in another block) are set according to the chosen client .
    I think this is made with <dialog> and some triggers.
10) manipulate the widgets from the triggers.  For example enable/disable
    buttons, fields.
11) debugging the triggers  by "print"-ing to the console.   (are
there other simpler ways?)
12) when a field value is being modified,  is it possible to access in the same
   trigger both the OLD and the NEW value of a field?  This only makes sense
   for certain triggers .  The use case for this is :  if the NEW value
   is greater than a certain threshold,  the trigger would revert to
the OLD value.

Also, it will be perfect to have a reference of the properties and methods that
are visible to the triggers.

I hope these ideas are useful.


Many thanks,
Adrian Maier