Working with Web App Control Projects
You can use the Web App Control Project project type to extend X4 Web Apps with custom JavaScript functions in order to access the data and actions of the web app via JavaScript API functions. You can use <CustomControls>
to incorporate your own JavaScript code into a web app and call actions in order to interact with the web app. In addition, you can control the layout by setting property parameters. In order to use a custom control in a web app, you just have to reference the Web App Control Project in a Web App Project. A Web App Control Project contains the content which is displayed in the Web App.
Creating a Web App Control Project
To create a new Web App Control Project:
- In the X4 Designer, right-click in the Projects view and choose New from the context menu.
Choose Web App Control Project....
Alternatively, you can click New in the File menu and choose Web App Control Project....Enter a project name in the Project Creation Wizard dialog.
- Choose Finish.
Web App Control Projects have a pre-defined and non-modifiable folder structure which is created automatically when creating a new Web App Control Project.
Sources | Once a project has been created, this folder contains three files:
The Sources folder cannot be deleted, moved, or renamed.
You can, for example, also create a |
<Project>.webcontrol | Project-related file which is created automatically when creating a project. The first part of the file name is the project name. If needed, you can add a definition for the cookie consent in this file. To do so, you can enter any text in the fieds or provide information for a third-party service. |
Note:
Using the developer tools, you can display all files from a Web App Control Project in the browser without authentication.
Using Custom Controls in a Web App
Prerequisite
You have a Web App Project containing at least one technical process. For more information on creating Web App Projects, see Creating a new Web App Project.
The following sections explain how to connect a Web App Control Project with a Web App Project in order to use one or more custom controls in the Web App.
To embed a custom control:
- Open the Web App Project and double-click on the <Project>.wac file. Choose
SAMEORIGIN
in the X-Frame-Options drop-down in the HTTP Security Header section. Add the desired properties in the Dashboard.detail file in the Components folder.
In this file, you insert the desired custom controls using the<CustomControl>
element and reference the Web App Control Project you have created previously via the mandatoryproject
attribute.You can create additional detail components in the Components folder which you use, for example, to set layout properties.
In addition, you can define the following attributes for the<CustomControl>
element:Attribute
Description
horizontalAlign
Direction of the element flow. The order of the elements corresponds to their declaration.
Possible values:
left
(default)center
right
textOverflow
Specifies which action is to be performed when the control is full.
Possible values:
ellipsis
: Use...
to indicate that the text is continuedhidden
: truncate text, do not break whole wordswordBreak
: break within wordsallow
(default): wrap text within words
visible
Specifies whether the control is visible.
- Data binding (boolean) possible
Possible values:
true
/false
or string for data bindingAttributes with description for iframe settings in sandbox mode allowForms
Allows the page to submit forms.
Possible values:
true
(default): Forms can be submitted.false
: Forms may not be submitted.
allowModals
Allows the page to open modal windows.
Possible values:
true
(default): Modal windows can be opened.false
: Modal windows may not be opened.
allowPointerLock
Allows the page to use the Pointer Lock API, an API that provides input methods based on the movement of the mouse over time.
Possible values:
true
: The Pointer Lock API is used.false
(default): The Pointer Lock API is not used.
allowPopups
Allows the page to open popups.
Possible values:
true
: Popups can be opened.false
(default): Popups may not be opened.
allowTopNavigation
Lets the resource navigate the top-level browsing context (named
_top
).Possibles values:
true
: Navigation in the the top-level browsing context is possible.false
(default): Navigation in the the top-level browsing context is not possible.
Within the<CustomControl>
element, you use the<APIAction>
element to specify the API functions to be used in the web app. The name of the function to be called is specified with the mandatoryname
attribute.
In addition, you can define the following attributes for the<APIAction>
element:Attribute
Description
componentName
Name of the component which is the target of the navigation at the end of the action.
Possible values: any string
externalLink
Specifies an URL here.
Possible values: any URL
externalLinkTarget
Specifies an external link.
Possible values:
new
(default): The page is opened in a new tab.same
: The page is opened in the same tab.
process
- Path to the
.wrf
file. The technical process must be contained in theServices/Processes
folder. The path is specified relatively to theServices/Processes
folder.
Possible values: any string (URI)
- In the Web App Control Project, adjust the index.html file in the Sources folder and add the desired elements.
- Open the web app in the browser. You will find a list of the supported browsers here.