Web Development Basics
Screen Lifecycle
This lesson is part of the Developing OutSystems Web Applications course.
LEARN MORE

Transcript
Hello and welcome to the screen lifecycle lesson, in this lesson we will highlight
how web applications work under the hood, which is quite different from normal
desktop applications, in case you come from a different technology. In the
process we will mention two or three OutSystems concepts so that you know how
they fit within the lifecycle of a page render in a web application. So, how do we
get an application page or screen available in our computer so we can
interact with it?
Well, first the user needs to click on a link or write in a URL in his browser
This will point him to a particular page in our application. When he does that, the
browser on his local machine sends a request to a server somewhere else in
the world. The server upon receiving this request will send a response with the
resource that was required of it. And finally the browser takes that resource,
in whatever format it is, and renders it, presents it to the user on the screen. Steps
one and two in the previous diagram are fairly simple to understand, you just
open the browser, you type in the URL and the browser sends a request to the
server where the application is hosted. Step three is where it gets interesting
this is where we're going to discuss how the server responds to the request.
There are actually two types of possible responses that the server can send
depending on the nature of what was requested. The first one is if you
request the static resource, that's when you request something that doesn't need
any processing, for example, you ask to download a PDF, or a zip, or an image.
So there is no code involved producing this response. Web applications however
take care of dynamic requests, whereby you request something that will need
some processing to send a response back. So the server will execute some sort of
code, some sort of logic, gather any data that it needs
and produce a dynamic response for you, normally an HTML file. When an OutSystems
server receives requests for dynamic content, a screen on your
application, the first thing that happens is the variables of the screen are born.
You don't need to know all of these details but just so you have an idea
there's input parameters and there's local variables. The input parameters, you can
actually push the values into the input parameters via the URL. These variables
obviously only exist during the rendering of the screen, so their scope
is limited to the time where the server is rendering the screen for the user.
Next, and before the server builds the visual part of the page, it needs
obviously to gather the data necessary and do some processing to produce that
visual page. This is done in an action called the preparation, this action
contains code that runs before the screen is actually build and you
normally find data queries and some logic that prepares, as the name indicates,
the building of the screen. After the preparation completes, the
server can then start building the screen, the visual part of the screen.
It does so from the top to bottom using widgets. Widgets are just visual
controls that are bound to the data that you have fetched in the preparation. Once
the building of the screen has completed the server can then send this response,
this dynamic screen, back to the user browser. And finally when the response
arrives to the browser, obviously the browser renders it to display it to the
user and we have a sample here of a screen from an OutSystems application.
So, as you can see, the lifecycle of pages is actually quite simple, the request is made
to the server, the screen variables are initialized, the preparation runs its
code, the screen is built, it is sent back as a response to the browser and it is
displayed to the user. And this is the life cycle of an application screen
in a nutshell. See you guys in the next lesson!