Application
Just like in a VCL application, a TMS WEB Core application has a singleton TApplication
object. The application is mainly responsible for creating and managing forms and provides in addition a couple of methods, properties and events to help in various ways. The Application
object is also responsible to retrieve various formatting settings (date, time, numbers) from the browser locale.
Normally, the IDE will automatically generate the needed code so the main application form is created. Following methods, properties and events are available:
Property | Description |
---|---|
Application.Active: boolean | Read-only property that returns true when the application is running in the active tab of an active browser window. |
Application.CreateForm(AInstanceClass: TFormClass; var AReference); | Creates a new instance of a form class. The new form instance is returned via the AReference parameter. Note that creating a new form involves loading the form HTML file and as such, this is an asynchronous process. |
Application.CreateForm(AInstanceClass: TFormClass; AElementID: string; var AReference); | Creates a new instance of a form class. The new form instance is returned via the AReference parameter. The form content is loaded in the HTML element set via ElementID . Thus, the form is hosted in the element in the form that contains it. Note that creating a new form involves loading the form HTML file and as such, this is an asynchronous process. |
Application.CreateForm(AInstanceClass: TFormClass; AElementID: string; var AReference; AProc: TFormCreatedProc); | Overload of the CreateForm() method that has an extra parameter AProc . This allows to pass a procedure pointer for the procedure that will be called when the asynchronous creation of the form is ready. |
Application.CreateForm(AInstanceClass: TDataModuleClass; var AReference); | Creates a new instance of a data module |
Application.AppContainer: TElementID | Sets the HTML element ID for the HTML element in which TwebForm instances will be created. Default Application.AppContainer is set to ‘body’, putting the new created form instances in the document body. |
Application.ErrorType | Defines the type of error messages that is displayed. aeSilent : non-obtrusive message in the browser console. Default when application is compiled in release mode aeDialog : HTML dialog with error message centered in browser window aeAlert :Javascript alert with error message aeFooter : Rectangular area in footer of browser window containing error message |
Application.FormCaptionHeight: integer; | Sets the dialogs caption height throughout the application. The default height is 22. |
Application.LoadForm(AForm: TCustomForm; AFormFile: string); | Loads the HTML file corresponding with the form instance. This is an asynchronous process. |
Application.InitFormatSettings(const BrowserLocale: string); | This allows to override the automatic initialization of format settings from the default browser locale. See Appendix for possible browser locale values |
Application.Navigate(AURL: string; ATarget: TNavigationTarget); | Method to navigate from the application to a given URL . With the ATarget parameter it can be set to navigate to the URL in a new browser window or in the window where the current application is running. |
Application.Download(AURL: string); | Starts the download of a file from the application from location AURL |
Application.DownloadTextFile(const AText: string; AFileName: string); | Starts the download of a text file from the application with content of the text file set as AText |
Application.DownloadBinaryFile(const Data: TJSUint8Array; AFileName: string; ANewTab: Boolean = false); | Starts the download of a binary file from the application with content of the binary file set as Data , an array of bytes. When ANewTab = true, the download is started in a new browser window |
Application.DownloadBinaryFile(const Data: TJSBlob; AFileName: string: ANewTab: Boolean = false); | Starts the download of a binary file from the application with content of the binary file set as Data available in TJSBLob format. When ANewTab = true, the download is started in a new browser window |
Application.DownloadBinaryFile(const Data: TBytes; AFileName: string: ANewTab: Boolean = false); | Starts the download of a binary file from the application with content of the binary file set as Data available in TBytes dynamic array format. When ANewTab = true, the download is started in a new browser window |
Application.EXEName: string | Returns the application URL |
Application.GetColorScheme: TApplicationColorScheme | Function returns whether the browser is running on an operating system with a regular color theme or a dark color theme. TApplicationColorScheme = (csNoScheme, csLight, csDark);csNoScheme : No operating color scheme could be detectedcsLight : Operating system has a default light color themcsDark : Operating system has a default dark theme |
Application.Themed: boolean | When true, the forms in the application and its controls will automatically adapt their color to match the operating system default color theme being csLight or csDark . |
Application.InsertCSS(CSSID, CSSFile: string); | Insert a CSS library reference with CSSID dynamically into the application main form HTML |
Application.RemoveCSS(CSSID: string); | Removes the CSS library reference with CSSID dynamically from the application main form HTML |
Application.ActiveForm: TForm | Returns the active form of the application |
Application.AutoRouteForm: boolean | When true, a form classname can be passed as a hash on the URL and then the application will automatically create and display a form of this classname. |
Application.HintClassName: string | Sets the classname for hints displayed when the form is a Bootstrap form |
Application.HintHidePause: integer | Sets the time in milliseconds after which the hint hides when the mouse hovers a control. This applies to Bootstrap forms |
Application.HintPause: integer | Sets the time in milliseconds after which the hint is displayed when the mouse hovers a control. This applies to Bootstrap forms |
Application.HintPosition: THintPosition | Sets the position of the hint displayed relative to the control. The options are hpLeft, hpTop,hpRight, hpBottom. This applies to Bootstrap forms |
Application.IsOnline: Boolean | Read-only property returning the online status of the application |
Application.IsMobile: boolean | Read-only property returning whether the web application is running on a mobile device (smartphone or table) |
Application.MainForm: TForm | Returns the main form of the application |
Application.ObjectURL(Afile: TJSHTMLFile): string; | |
Application.RouteForm(AParameter: string); | Automatically start the form with class name passed as request parameter form=TFormClassName |
Application.RunScript(AScript: string); | Executes a block of JavaScript code immediately |
Application.MainForm | Returns the form instance that is the current active main form of application. |
Application.Parameters: TStrings; | Returns the list of possible optional URL request parameters with which the application was started |
Application.Language: TUILanguage | Sets optionally the application language. When the application language is set, it is possible that a language specific HTML file for a form is loaded. Default, Application.Language is set to lNone. When Application.Language is set to a different value, the HTML file loaded for a form gets a language specific suffix. For example, when Application.Language is set to lGerman , the application will load for a form in unit1.pas and having the form HTML file named unit1.html as unit1_de.html. This way, it is possible to have different language specific HTML files and have the application load the desired HTML form file when the language is set. The list of supported languages and the used language suffix is found in the appendix. |
Application.ThemeColor: TColor | Gets and sets the application theme background color. This theme background color is used as form caption background color when popup forms are created. |
Application.ThemeTextColor: TColor | Gets and sets the application theme text color. This theme text color is used as form caption text color when popup forms are created. |
Application.ThemeButtonClassName | Gets and sets the application CSS style classname for the buttons created on dialog boxes. |
Application.OnActivate | Event triggered when the browser or browser tab where the app is runnnig becomes the active or inactive browser window. The Active parameter returns whether the app is running in the active brower or browser tab or not. |
Application.OnError | Event triggered when an error occurs in the application. This can be a Pascal exception or any HTML DOM specific error. The event passes the information about the error in the parameter AError : TAppplicationError. When the Handled parameter is set to true, the standard error is not longer performed. |
Application.OnException | Centralized application level exception handler. |
Application.OnExit | Event triggered when the user navigates away from the application or closes the browser tab where the application is running. |
Application.OnFontCacheReady | Event triggered when fonts were successfully loaded in the cache. Font caching is used for client-side PDF generation |
Application.OnHashChange | Event triggered when a hash query parameter in the application URL changes. When the application was started with myapp.html and then the URL myapp.html#newform is used, the OnHashChange event will be triggered. When used in combination with AutoRouteForm , the form classname can be passed as a hash and this form will be created when the hash changes. |
Application.OnImageCacheReady | Event triggered when images that were set to be loaded by setting the URL are finished with loading asynchronously . It might be necessary to force a repaint of controls from this event. |
Application.OnOnlineChange | Event triggered when the online status of the application changes. That is, when the device goes from online to offline or vice versa, this event is triggered |
Application.OnOAuthToken | This event is triggered when the token is returned from a REST API service after authentication & authorization through a popup window. |
Application.OnOAuthCallBack | This event is triggered when the REST API service against which authentication & authorization is performed by means of a popup window is doing a callback to the application from where it was started. |