Strengthen application security, enhance users experience easily & automatically
With the introduction of Dynamic Web Objects to DataFlex, developers are easily able to apply the power of dynamic objects to their web applications.
Examples of when to use Dynamic Web Objects include creating:
To help developers get the most out of this technology for their web applications, let us review the various resources available
To start, an object is an instance of a class. It is a dynamically allocated block of memory that is defined by its class type. To utilize the functionality of a class, you instantiate it as one or more objects. Read the DataFlex Help for more about Objects.
Dynamic objects refer to DataFlex objects that are created at runtime as opposed to at design time. More specifically, the actual properties of these objects are only loaded when the objects are first initialized. This means the properties can, for instance, be stored in a database and diﬀer per user for creating unique user experiences when logging in.
Dynamic Web Objects refer to dynamic objects that are instantiated in web applications. Read the DataFlex Help for more about Working with Dynamic Web Objects.
This example dashboard in the Plato sample app demonstrates using Dynamic Web Objects to show different content for different users:
DataFlex developer Dan Walsh used Dynamic Web Objects to easily customize the user login and dashboard views for a major legal firms client portal, avoiding clutter and enhancing security.
The login view by default is a conventional login dialog, but is reconfigured for first-time registrants, Dan says. The portal has different functions for pre and post login. Prior to the introduction of dynamic objects, both views contained all the necessary objects which were rendered and/or made visible using property settings. Now, with Dynamic Web Objects, this process is much simplified and more secure.
To see how Dan implemented Dynamic Web Objects, view his source code for both before and after the implementation of the dynamic objects, and the presentation Dan gave at the DISD Developers Conference in 2020, download this zip file.
View of the Client Portal demonstrating Dynamic Web Objects:
The DataFlex Learning Center offers various video courses for developers. There are two lessons and two courses that cover the current topic of interest: TRAINING Dynamic Objects, Dynamic Objects, Dynamic Objects Library, and Advanced Dynamic Objects.
The first two are lessons presented at EDUC 2020 and deliver an overview of what dynamic objects are, their implementation for the web environment, and examples on how to use them in your application. The development environment used is DataFlex 19.1, when dynamic web objects were introduced through a separate library.
If your development environment is DataFlex 19.1, the Dynamic Objects Library course is for you. It introduces developers to the library that enables DataFlex 19.1 development environments to work with dynamic web objects. The library itself must be downloaded separately from our website.
If you are using DataFlex 2021 or higher, however, the ability to work with dynamic web objects is included in the product right out of the box. After reviewing the information in the DataFlex Help recommended earlier and one of the lessons that explains the implementation of dynamic web objects, the Advanced Dynamic Objects course will demonstrate how to create, configure, and modify dynamic web objects.
To better demonstrate the use of dynamic web objects in applications, a few examples were created to let developers explore the mechanics of these objects.
For a working view of Dynamic Web Objects in the browser, the Web Order example has a dynamic objects demo. To access that example, start DataFlex Studio and select to open the WebOrder workspace.
First, run the example and select Demo | Dynamic Objects to see how dynamic web objects are used in this application:
Next, take a closer look at the specific example by opening the DemoDynamicObjects.wo in the Studio. You will see the definition of the objects in cWebDynamicObjectContainer and the implementation of supporting methods that bring those objects to life:
Lastly, dig into the source code to see how it is done by searching for the cWebDynamicObjectContainer and placing breakpoints in different areas of the source code to watch the behind the scenes of the dynamic web objects framework (view large image):
Another resource that demonstrates a working example of Dynamic Web Objects is Plato, the SQL-based DataFlex 2021 sample application for a fictitious chrome plating business. Plato illustrates the range of features and functions necessary to run any business, and it provides developers with full source code and documentation from which they can learn how business requirements are implemented in DataFlex.
Developed by Sture Andersen, Platos Dynamic Web Objects example stores settings in a table where each record corresponds to one value. Values will be represented by a cWebForm object, but it is possible to specify that a cWebCombo or cWebCheckbox should be used instead.
The functionality is implemented in a subclass of the cWebDynamicObjectContainer class that also includes methods for saving and retrieving data.
To see Platos Dynamic Web Object example in action, first read Understand and Using Plato (PDF) and then download and install the complete Plato application. (Note that you must have DataFlex 2021 Studio installed.)
Once you have the Plato workspace installed, run the example application by logging in as John (password John).
In the top-left hamburger menu, select "Settings" and then "Plato Settings".
The interface you will be shown is generated dynamically based on parameters that are set up in PlatoSettingsManager.pkg:
Next, open the PlatoSettingsManager.pkg file to see how this corresponds to the user interface (view large image):
Lastly, locate the object oPlatoSettingsView class (Ctrl+Shift+F) where you can set a breakpoint on "Send LoadSettings" in the procedure OnLoad. By single stepping your way through, you can learn from watching the execution of the code.
As you can see, Dynamic Web Objects are a very versatile, powerful tool for DataFlex developers to have in their toolbox!
To discuss this topic with other developers, visit the DataFlex forum on Web & Mobile Applications.
While in the DataFlex forum, take the opportunity to explore other topics and participate in online developer discussions about developing mobile, web and Windows business applications.