Try OpenEdge Now
skip to main content
Introducing the Progress Developer Studio for OpenEdge Visual Designer
Creating the Department Window : Adding the code that completes data binding
 

Adding the code that completes data binding

At this point, the UltraTree control is bound to bindingSource1 as its data source. To complete the data binding procedure, you must add the code that binds bindingSource1 to the ProDataSet, created in beDepartment.cls. The code is very similar to the code you added to customerForm.cls in Adding the ProBindingSource control to a form.
To bind bindingSource1 to its data source:
1. With departmentForm.cls open in the ABL Editor, define a variable for the service adapter by adding the following declaration:
DEFINE PRIVATE VARIABLE oServiceAdapter AS openedge.tutorial.services.serviceAdapter.
You can add it to the other variable declarations, which appear after the CLASS declaration at the beginning of the file.
2. Define the open and close query methods by adding the following code before the DESTRUCTOR statement:
/* openQuery */
METHOD PRIVATE VOID openQuery():
bindingSource1:handle = oServiceAdapter:getDatasetHandle().
END METHOD.

/* closeQuery*/
METHOD PRIVATE VOID closeQuery():
oServiceAdapter:closeQuery().
END METHOD.
3. Find the CONSTRUCTOR declaration in the file.
4. Add the code shown in bold:
CONSTRUCTOR PUBLIC departmentForm ( ):

SUPER().
oServiceAdapter = NEW ServiceAdapter("Department").
InitializeComponent ( ).
openQuery().
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.
END CONSTRUCTOR.
This step implements data access by creating a service adapter that uses a ProDataSet (Department) that is defined in BEDepartment.cls.
5. Find the DESTRUCTOR declaration in the file.
6. Add the code shown in bold:
DESTRUCTOR PUBLIC departmentForm ( ):

closeQuery().
IF VALID-OBJECT(components) THEN DO:
CAST(components, System.IDisposable):Dispose().
END.

END DESTRUCTOR.
7. Press CTRL+S to save your changes.