Overview
In this document, we will explain how the Pages that we used on the Application are defined by Controls and how these controls need to be linked by Actions that are necessary to establish an interaction between DB and the Application’s UI.
How to create a Table and Stored Procedure in Project DB?
It’s important to reinforce the idea that all the Project’s information come from the DB through Stored Procedures (SP) and these data is readable in the Application through the Controls. This document will show that there’s another way to interact with the DB information creating Actions that can modified the information in our DB
As precondition, we need to create a new table in SQL to verify the interaction between Dataset, Controls and Actions.
This table has 3 columns “Nombre”, “Cargo” and “FecIni”. Then we can proceed to create a Stored Procedure related to “Test Empleados” that will insert new values and consequently will select and display the new input information.
Once that the new Table and Stored Procedure are created, we can go to Wayfast application.
Click “End Task” button related to Project’s requirement. This step is only needed for synchronization of the new Table and Stored Procedure generated in DB.
Now we have the new objects available in Wayfast Application to associate with Controls and Actions.
How to create Controls to interact with Application?
To begin, navigate to Pages and open a specific Page’s Detail form. In another document, we learnt how to create new Controls. Focus on Controls section. Then select “Inputbox” control and click “New” button
A popup will be displayed to fill the information related to new control. Complete the “Field” with the fieldname that we are going to identify the control in our page.
Turn to “Layout” tab and establish the place in Application’s page that this new input box will be displayed. In the example, the alignment is beside the previous control created and we define the length that user can input for this field.
At this point, it’s important to follow the structure that we previously defined in “Test Empleados” db table. In this case, we are going to create only 2 inputbox controls for “Nombre” and “Cargo”. “FecIni” column table will be logged at the moment that we insert the value in DB.
Click “Accept” button in popup to create the “Name” inputbox control and repeat the same step for “Cargo” inputbox control.
Controls section now display the 2 input fields that user can add through the page and also there are 3 “Grid_Column” controls. This columns are going to retrieve the readable information from DB. Keep in mind that we created the Stored Procedure for this purpose in previous steps.
Relationship between Controls & Dataset is explained in the previous tutorial.
Finally, create a new “Button” control to trigger the insert value in DB.
This button is named as “Agregar”. In the example, everytime that Application User input the “Nombre” and “Cargo” inputboxes and then click “Agregar” button, the new value are going to be added in “Test Empleados” table.
How to add Actions in Controls?
Wayfast allow us to create a new action at the same time that we create the control. In the “New Control” popup, click “Actions” tab
Click “New Action” button
This “Action” will be a “Stored Procedure” type for the reasons that we described previously in this document. After we select the option, Wayfast will display 2 options on “Action” field:
FORM is used in Wayfast as unique execution in the whole page.
LIST is an action that can be executed as many times that it’s requested. Mostly this is needed when the page has multiple registries in grid views.
Search the “SP_AgregarEmpleado” Stored Procedure created. Add “&InpNombre” and “&InpCargo” parameters that are connected to the Column’s table “Nombre” and “Cargo”. In Wayfast, we associate the entry parameters using an “&” sign instead “@” sign.
NOTE: “Return value” field has a complexity and depends on the type of logic that we created in our Stored Procedure. If certain information is needed after executing the SP, we can return a value as a variable and this value is available for next action created.
In this ALTER PROCEDURE, we introduce an “IF” variable condition as flag.
After clicking “Accept” button, Controls and Actions are updated in Page’s detail.
How to modify the execution in Dataset now that contains an Action associated?
It’s important to verify how the Dataset execution is going to work with Controls and Actions setup.
Click “Edit” lookup icon related to Dataset
A popup is displayed with Dataset settings. Notice that originally “Execution Type” under Dataset was set as “Pre” to execute the dataset while the page is loaded which is helpful to get the information available from the very beginning.
Turn to “Data Binding” tab
Now that the page has actions that will insert new data, this type of execution needs to include a “Control run” related to “Button” control previously added. Click “Add relationship” button once the control is added.
Click “Accept” to save the changes.
How the Application works after all the definitions?
Now that the page is setup with Dataset, Controls and Actions, we can verify that the interaction is working as expected. Wayfast allow us to make a preview by click on “Preview” button at the top right corner
Layout is displayed on screen with the input fields created and the button to add the new values in “Test Empleado” table on DB.
Notice that the entry is displayed on screen after clicking “Agregar” button. This is possible due to the “Control Run” setting that was added in Dataset to post the information written in DB. This setting make a postback that execute again the dataset to retrieve the new entry.
Recap
In the first part, we learnt about how to Pages interact with DB by creating Datasets. Then we made a first approach using SQL to create an easy Stored Procedure that was linked to Dataset. In the second part, we explained how the Controls under pages can display in many different ways the information available on DB, assigning the place and source. In the next tutorial, we will learn how to connect the Controls with Actions that user will have in pages to interact with the Application.