We’re sure you’ll be pleased to explore the new features Qodly Studio for 4D brings with 4D 20 R7.
Keep discovering this powerful platform—a robust and user-friendly solution for building business web applications with minimal coding effort.
Integrated within 4D, Qodly Studio for 4D allows you to leverage existing business logic developed for desktop applications.
Let’s dive into the details and see how your app can deliver more than just data while offering a dynamic user interface and strong data protection through setting up privileges.
DELIVER MORE THAN DATA WITH THE NEW 4D.IncomingMessage class
With your Qodly app, you can now easily enable file downloads for your end users.
Use the new 4D.OutgoingMessage class, which your app can retrieve via an ORDA function call or a singleton function call.
This leads to returning web content complete with a body, HTTP headers, and status codes ready for the browser to process.
Just implement a function returning an instance of the new 4D.OutgoingMessage class, set up the function call, and the web browser handles the 4D.OutgoingMessage class automatically. No extra steps are needed!
Read this blog post to learn more.
example
In the example below, the getThumbnail() function of the Products dataclass receives as a parameter a product name, a width, and a height. It returns to the browser an instance of the new 4D.OutgoingMessage class whose body contains a thumbnail of the product image with the required size.
Note the use of the new onHTTPGet keyword. If this keyword is applied to a function, this function is callable with a GET verb! Downloading a file can be done by simply clicking a link.
Class extends DataClass
exposed onHTTPGet Function getThumbnail($name : Text; $width : Integer; $height : Integer) : 4D.OutgoingMessage
var $file:=File("/RESOURCES/Images/"+$name+".jpg")
var $image; $thumbnail : Picture
var $response:=4D.OutgoingMessage.new()
READ PICTURE FILE($file.platformPath; $image)
CREATE THUMBNAIL($image; $thumbnail; $width; $height; Scaled to fit)
$response.setBody($thumbnail)
$response.setHeader("Content-Type"; "image/jpeg")
return $response
It’s so easy to set up this function call in Qodly!
And here is the result in action!
new OnPrivilegeChange event
If you have set up privileges to protect your data, access to data is not granted if the appropriate privileges are not in the Session.
This can lead to annoying scenarios like this one:
- The user is not authenticated, and the session contains no privileges, so loading a Qodly source (referring to data protected by permissions) at application startup fails because the appropriate privileges are missing
- The user authenticated, the appropriate privileges are now in the session, but … the application is not notified of this to load the Qodly source
Thanks to the new OnPrivilegeChange event available on the Page, you can trigger an action (standard action, navigation, or function call) when the privileges in the Session on the server have changed.
example
In the example below, the HealthCare application has a header displaying statistics (number of doctors, number of patients, …). This header also displays the top doctor (the doctor having the greatest amount of appointments). It is a shared Qodly source (mostBusyDoctor) loaded at application startup.
As long as the user is not authenticated, this information is unavailable because access is not granted to read the doctors. Once the authentication is done, thanks to the new OnPrivilegeChange event set up on the Header page, this datasource can be loaded.
And here is the result in action; look at the header!
Roles and privileges – Show/hide the inherited privileges
If you have already used the Roles and Privileges interface and set up some nested privileges, you know it is a good thing to view which permissions are inherited from others.
But sometimes, you must focus on a lighter view with only the permissions you explicitly set up for a privilege.
This is now possible. Just activate a toggle for that!
Don’t wait any longer to try that new Qodly studio for 4D features and make your web app user-friendly and powerful!