Web Extension Toolkit

Unofficial Content
This documentation is valid for:

Web Extension Toolkit is a set of External  Objects to solve typical problems in Web Applications.

For example:

  • Close Popups programmatically
  • Open new window/browser tab
  • Management of the address bar of the browser (change, back, forward, etc)
  • Execute JS code
  • Send error messages and warning to browser console
  • Subscribe to events of:
    • Popup closure
    • On Ready of web apps
    • onUnLoad (when closing a web page)
  • Display native Web dialogs for:
    • Confirmation
    • Alerts
  • Use of WebSocket API (management of the WebSocket low level API)

Samples:

Sample 1: Open in new Window

Event 'OpenNewWindow'
    if (&UseAdvancedOptions)
        Extensions.Web.Window.OpenNewWindow(&Url, "",&WindowOptions)
    else if (&OpenMultipleWindows)
        Extensions.Web.Window.OpenNewWindow(&Url,  'myNewWindow-1')
        Extensions.Web.Window.OpenNewWindow(&Url2, 'myNewWindow-2')
    else
        Extensions.Web.Window.OpenNewWindow(&Url)
    endif
Endevent

Event 'Close Window'
    Extensions.Web.Window.Close('')
EndEvent

Event Extensions.Web.Window.OnClose(&windowName)
    msg(&windowName + "has beed closed!")
EndEvent

In New Window options: 

windowoptions_png

Note: To open in new Tab, use the method with only URL parameter.

Extensions.Web.Window.OpenNewWindow(&Url)

Sample 2: Close Popup programmatically

Event Enter
    Popup1.Popup()
Endevent

Event 'Close'
    Extensions.Web.Popup.Close()
Endevent

Event Extensions.Web.Popup.OnPopupClosed(&PopupName)
    msg("popup has been closed: " + &PopupName)        
EndEvent

 

Sample 3: Run JS code, show alert and confirm dialogs:

Event 'RunJS'
    Extensions.Web.WebInterop.RunJS(&scriptToRun)
Endevent

Event 'LogError'
    Extensions.Web.WebInterop.LogError(&logMessage)
Endevent

Event Extensions.Web.WebInterop.OnReady()
    msg("Onready!")
EndEvent

Event Extensions.Web.WebInterop.OnUnload()
    Extensions.Web.Dialog.Alert(!"Exiting Page!")
EndEvent

Sample 3.1: Alert Dialog:

image_2019128163328_1_png

Event 'ShowAlert'
    Extensions.Web.Dialog.Alert(&logMessage) //&LogMessage: Message that will be display within Alert Dialog
Endevent

Sample 3.2: Confirm Dialog:

image_2019128163426_1_png


Event 'ShowConfirm'
    Extensions.Web.Dialog.Confirm(&logMessage) //&LogMessage: Message that will be display within Confirm Dialog
Endevent

Event Extensions.Web.Dialog.OnConfirmClosed(&UserResponse)   //&UserResponse: MUST be a Boolean Variable. 
    Extensions.Web.Dialog.Alert("User Confirm Response: " + &UserResponse.ToString())
EndEvent

 

Sample 4: Manage Browser History API:

Event 'PushState'
    Extensions.Web.History.PushState(&ResourceName)
Endevent

Event 'Replacestate'
    Extensions.Web.History.ReplaceState(&ResourceName)
Endevent

Event 'GoBack'
    Extensions.Web.History.GoBack()
Endevent

Event 'GoForward'
    Extensions.Web.History.GoForward()
Endevent


Installation instructions:

1. Download .ZIP file from Marketplace
2. In Genexus, Menu -> Knowledge Manager -> Open "Manage Module References".
3. In the dialog on the left, right click -> "Upload from file". Select the .opc file that is inside the .zip.
4. Install
5. Copy file "gx-web-extensions.js" (inside .ZIP) to the WEB folder.

(The ZIP also contains an example XPZ)

 

Usage Requirements:

//Needed for GeneXus V15 U8 or lower (ONLY)

  • .NET: Form.HeaderRawHTML += !'<script type="text/javascript" src="gx-web-extensions.js" data-gx-external-script=""></script>'    
  • .JAVA: Form.HeaderRawHTML += !'<script type="text/javascript" src="../static/gx-web-extensions.js" data-gx-external-script=""></script>'    

 

Troubleshooting:

javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/webinterop/extensions/web/SdtWindowOptions
  • Check if "Web\modules\Extensions.jar" has been copied to "WEB-INF\Lib" directory

js error: cannot read 'web' of undefined  or 404 not found
  • Check if file "gx-web-extensions.js" (inside .ZIP) has been copied to the Deploy static directory.