DecSoft App Builder

Http client description

The Http client is a non visual (don't appear in the screen at runtime) control that allows to made HTTP request from the app, so we can get information from a remote server, as well to upload information to it. It's a fundamental piece of the client apps, because, allows to download and upload remote information to be used in the app.

No matter what server software or server database is used, what the app do are HTTP calls with the right arguments, in order to retrieve information, and, in a similar way, made HTTP calls, with the right arguments, to upload information to the server, for example, to be inserted in a database: the client app is completely abstracted from what server software nor server database is used.

There is a Http client sample app included with the installation of DecSoft App Builder. Take a look to see this control in action!

Http client at designtime

The Http client control put at your disposition the below designtime properties or variables. Designtime means here that these properties are only available in designtime and not in runtime.

Http client at runtime

The Http client control put at your disposition the below runtime properties or variables. You can set almost all these variables in designtime, and, they are also available to be use when the app is running. Note that we named here these variables in a capitalized way, because is like you can see it in the designtime control's inspector, however, at runtime we use the lower camel case way.

Http methods

The Http client control put at your disposition the below methods. You can use these methods in runtime in order to perform various control related tasks.

Http client events

The Http client control put at your disposition the below events handlers:

Http client designtime properties

Http client Top property

Designtime. Integer variable. The Top property stores the top position of the control in pixels. This value is only take in consideration at designtime, since this is a non visual control, which do not appear in the screen at runtime.

Http client Left property

Designtime. Integer variable. The Left property stores the left position of the control in pixels. This value is only take in consideration at designtime, since this is a non visual control, which do not appear in the screen at runtime.

Http client Width property

Designtime. Integer variable. The Width property stores the width of the control in pixels. This value is only take in consideration at designtime, since this is a non visual control, which do not appear in the screen at runtime.

Http client Height property

Designtime. Integer variable. The Height property stores the height of the control in pixels. This value is only take in consideration at designtime, since this is a non visual control, which do not appear in the screen at runtime.

Http client Locked property

Designtime. Boolean variable. The Locked property determines if the control can be moved or resized in app view designer or not. Set a "false" value mean the control can be moved and resized. Set a "true" value (by default) mean the control cannot be moved nor resized. Remember that this control property is only for designtime and is not available in runtime.

Http client runtime properties

Http client Name property

Runtime. String variable. The Name control property stores the name of the Http client control as you set in designtime. The Name property value must be unique for the same app view, dialog or frame, that is, it's possible to have more than one "http1" in the app, if that controls resides in different app views, dialogs or frames. Note that you must consider this variable as read only: change the name of a control in runtime can cause unexpected results.

Http client Url property

Runtime. String variable. The Url control property stores the URL that is used when you made the HTTP call, by using the control execute() method. You can change the Url property at runtime anytime you need: the latest one is used when the next HTTP call is made.

Http client Method property

Runtime. String variable. The Method control property stores the HTTP method to be used when execute the HTTP call. You can use one of the "app.httpMethod.*" constants values to set this variable.

Http client Cache property

Runtime. Boolean variable. The Cache control property determines if the HTTP call server response must be cached or not. This variable is "false" by default, but you can set it to "true" in order to cache the server response of the HTTP call.

Http client ContentType property

Runtime. String variable. The ContentType control property determines how the data is send to the server. Default is "application/x-www-form-urlencoded", which is fine for most cases. Note: For cross-domain requests, setting the content type to anything other than "application/x-www-form-urlencoded", "multipart/form-data", or "text/plain" will trigger the browser to send a preflight OPTIONS request to the server. You can set this variable to "false" in order to not send any content type to the server.

Http client Timeout property

Runtime. Number variable. The Timeout control property can be established to a number of milliseconds to be taken as the HTTP call timeout. This variable is "0" (zero) by default, means no timeout is established.

Http client UserName property

Runtime. String variable. The UserName control property can be established to set the user name to be used in a basic HTTP call authentication.

Http client Password property

Runtime. String variable. The Password control property can be established to set the user password to be used in a basic HTTP call authentication.

Http client Response property

Runtime. Mixed variable. The Response control property stores the response retrieved from the server for the made HTTP call. This property is available in both the control Done event and the Fail event. The Response variable can be whatever the server send to the app, as simple as a string, or a more or less complex JSON object ready to be used by the app.

Http client StatusCode property

Runtime. Number variable. The StatusCode control property stores HTTP code of the made HTTP call. This property is available in both the control Done event and the Fail event.

Http client TextStatus property

Runtime. Mixed variable. The TextStatus control property stores the text status of the HTTP call after has been made. This property is available in both the control Done event and the Fail event. Possible values for the TextStatus variable (besides "null") can be "timeout", "error", "abort" and "parsererror". When an HTTP error occurs, the ErrorThrown property receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error."

Http client ErrorThrown property

Runtime. String variable. The ErrorThrown control property stores the text status of the HTTP call after has been made. This property is available in the control Fail event. Possible values for this variable are "Not Found" or "Internal Server Error."

Http client Request property

Runtime. Object variable. The Request control property stores the "jQuery Xhr" object that has been used to made the HTTP call. This property is available in both the control Done event and the Fail event

Http client runtime methods

Http client execute() method

Runtime method. You can use this Http control method to execute an HTTP call. See below how easy is to use the control Data property to set the arguments for the HTTP call. After the execute method is called and when we get the server response, the control Done event or the control Fail event are fired.

Http client setHeader() method

Runtime method. You can use this Http control method to set an specific HTTP header to be send with the HTTP call. This method admits the below arguments, both of them required:

Name Type Description
headerName String The header name to be established for the HTTP call.
headerValue String The header value to be established for the HTTP call.

Http client events

Http client Done event

The Done event handler is fired when the HTTP call has been executed and the server response is ready for the app. The server response is available in the control Response property and you have the HTTP status code in the Status property.

Http client Fail event

The Fail event handler is fired if an error occurs. The server response is available in the control Response property and you have the HTTP status code in the Status property. Look also at the ErrorThrown property.

Http client events variables

The below JavaScript variables are available in all the referred Http client control events handlers:

Name Type Description
self Object Stores the control object. This is a shortcut to the control variable, and it's available since we are talking about specific control events.
view Object

Stores the current app view or dialog. This variable allow us to access to that view or dialog properties and methods and also their controls properties and methods. For example, you can access to a control properties using the variable "view.yourControlName", suposing the control is named "yourControlName".

views Object Stores all the loaded app views. Note that loaded views mean that the app views has been previously show to the user. It's possible to access to the app view controls properties like "views.view1.yourControlName", suposing the view is named "view1" and the control is named "yourControlName". In the same way we can access to other controls of the view and to other loaded views and their controls.
frames Object Stores all the app frames. You can use this variable to access to all the app frames and their controls.
dialogs Object Stores all the app dialogs. You can use this variable to access to all the app dialogs and their controls.
app Object Stores all the app properties and methods. You can use this variable to access to all the app properties and app methods.