Genies for the UX Component

Description

In this article, we'll see how Alpha Anywhere can write data binding code. In Server-side Action Scripting, we see how Alpha Anywhere can generate other server-side actions.

We start by inserting a new control into a UX Component, selecting Create multiple new controls at once, and clicking the Populate list from a table link. In this example we picked the Customer.dbf table from AlphaSports, and left Include data binding information checked.

Dialog Populate List From Customer With Binding Info

After pressing OK, we have all the fields we need. What's more, the field types match the corresponding types in the table. Here we see an automatically generated numeric field type.

Dialog Automatic Numeric Field Type

We also have automatically generated binding information for the field, seen at the lower right.

Dialog Automatic Data Binding Information

The data binding panel of the dialog definition has four actions. We have expanded the descriptions for the two major actions.

Dialog Data Binding

We aren't stuck with the bindings we got from the original table. We can create the tables to match the controls we have in the dialog. This is a three-step process.

Make Tables For Dialog Controls

In the first step, we define our table aliases (abstract table names) and fields. Here we are setting the lengths of all the character fields at once.

Define Table Aliases And Fields

The table properties are relatively simple. Here we have chosen SQL, a connection string, and a table name to create on the connection.

Define Table Properties

At this point we can actually create the table or tables, or if the database we need is not available, save the settings for later creation. The settings will be saved even if we create the table.

Dialog Create Tables

Going back to the data binding pane, we can now bind the dialog controls to the fields of the SQL table we just created.

Bind Dialog Controls To Table Fields

The first step is to specify the tables. These are already set properly, because of the previous steps.

Dialog Bind To Table

The second step is to bind the controls to the appropriate fields. Again, these are already set properly, because of the previous steps.

Dialog Bind Controls To Fields

Now we need to actually generate the code. We do that with a server-side action in the afterDialogValidate event handler.

Server Side Actions Select An Action

We pick the save action and check the debug option.

Save Submitted Data To Tables

The server-side action goes into the event handler code as

ExecuteServerSideAction("Save Data::save_customer")
Save Data Server Side Action Script

We checked the option to generate SQL debug output, so when we add a submit button and test the dialog we can see the SQL actions.

Dialog Data Binding Sql Debug Output