Creating a Custom Widget from Scratch
This page details an advanced example of creating a custom widget from scratch. While this widget is shipped with Profound UI, the widget is not built-in to the product. If you require a Google Maps widget for your application, we recommend using a basic iFrame widget that points to the Google Maps URL instead.
The attached files show a simple example of the recommended way of adding a Google Maps ‘widget’ to your application.
DSPF:
JSON files can be opened directly in the Visual Designer by following these steps:
Download the file to your PC
Use the Open… → Local File option:
Select the file from the Windows File Explorer
Select the Open button
RPG program:
Creating a custom widget from scratch requires you to write JavaScript code to perform the following steps:
Add a base widget using the pui.widgets.add() API
Add the necessary custom properties using the pui.addCustomProperty() API
Add an entry to the Widgets Toolbox using the pui.toolbox.add() API
For more information on these API functions, refer to the Widgets Development API section of the documentation.
All JavaScript code should be saved into an external file that is placed in the /www/profoundui/htdocs/profoundui/userdata/custom/widgets IFS directory.
The completed example widget can be found in the Profound UI Visual Designer in the Custom Widgets section:
Example: Google Maps Widget
In this example, a custom Google Maps widget is created.
// Add the base widget
pui.widgets.add({
// widget name - this is placed into the standard "field type" property
name: "google maps",
// the default id prefix - used to assign id's when the element is first created
newId: "Map",
// pull-down menu name
menuName: "Google Maps Widget",
// default properties for the widget
defaults: {
"width": "400px",
"height": "300px",
"z index": "25",
"background color": "#FFFFFF"
},
// property setter functions
propertySetters: {
// this will fire when the field type property is set to "google maps"
// initialization code for the element should go here
"field type": function(parms) {
if (parms.design) {
// design mode content creation code goes here
// add preview image
var img = document.createElement("img