Akumina Developer Documentation

Akumina Developer Documentation

  • API
  • Docs
  • Blog

›Widget Info

Akumina

  • Quickstart

Yo Akumina

  • Yo Akumina
  • Start with Yeoman
  • React
  • Simple template

Widget Builder

  • Widget Builder Structure
  • Akumina Widget Builder
  • Skipping instances
  • Token replacement for widget properties

Widget Development Quickstart

  • Setting up the Project
  • Configuring .env file
  • Configuring - akumina.sitedployer.config.json file
  • Configuring - akumina.config.json file
  • Extras

Widget Info

  • Akumina Widgets Overview
  • Building a New Widget Instance
  • Widget Views
  • Widget Properties
  • Global vs Local widgets (Widget Scoping)
  • Akumina React Widgets
  • Callbacks
  • RenderChildWidgets
  • Vendor Package List

Virtual Page Builder

  • Akumina Virtual Page Builder
  • Using Virtual Page Layouts
  • Creating a Custom Layout

Stream Card Builder

  • Installation
  • Stream Card Builder
  • Custom Cards
  • Activity Comments Config
  • Akumina Activity Stream PUSH Subscription using PowerAutomate to connect to ServiceNow
  • Akumina Activity Stream PUSH Subscription using PowerAutomate to connect to Dynamic 365

Site Deployer

  • Overview
  • Version 6.0
  • List Attribute Deployments
  • NPM Commands
  • SPA Updates and Deploying to multiple sites

Authoring

  • Content Action Event
  • Publish Validation Integration
  • Field Event Integration
  • CK Editor external plugins

Headless

  • Quickstart
  • Headless Teams support
  • Headless Troubleshooting

Modern

  • Overview
  • FAQ
  • Single Page Application
  • Modern Web Part Library
  • Google Analytics for Modern Pages

Site Creator

  • Overview
  • Adding A Custom Site Definition
  • Core Step Classes
  • Custom Site Definition Components
  • Custom Site Definition XML
  • Custom Subsite Definitions
  • Sample Step Code
  • Supported Tokens

Azure DevOps

  • CI/CD using Azure DevOps
  • Setting up a build to deploy a site package
  • Setting up a build to deploy file to App Manager hosted in an app service

Configuration

  • Configuration Context Overview
  • Edit the Redis cache timeout
  • Using a key vault for the client id and client secret

Debugging

  • Debugging in Akumina

Advanced

  • Central Site Collection Support
  • Eventing OOB Digital Workplace Events
  • Working with custom JSX Views
  • Page Indexing

Service Hub

  • Quickstart

Patch Notes

  • Patch Notes

Callbacks

Overview

The purpose of this article will be to explain and demonstrate the provided functionality of callbacks in the Akumina Framework, specifically pertaining to widgets, and provide examples of how they can be used.

Natively Supported Callbacks

Pertaining to widgets, the Akumina Framework supports two callback functions by default:

  • callbackMethod
{
    "name": "callbackmethod",
    "friendlyname": "callbackmethod",
    "value": "",
    "type": "string"
}
  • uiCallbackMethod
{
    "name": "uicallbackmethod",
    "friendlyname": "uicallbackmethod",
    "value": "",
    "type": "string"
}

The differences between the two functions is the point in the widget lifecycle in which the functions are invoked. callbackMethod is invoked after the property bag for the widget has been finalized but BEFORE the UI is parsed. uiCallbackMethod, conversely, is invoked after the UI is parsed but before it is rendered to the user. The general idea behind the callback functions is to easily provide custom functionality to a widget, or a group of widgets, that is easily available to the widgets on the page and can be shared between multiple instances. For example:

Let's say you have several widgets that use an ItemID property. The ItemID property is used to provide uniqueness to DOM elements by constructing a custom ID value. However, due to the nature of the ItemID property, it is invalid HTML and needs to be sanitized before being rendered. To this effect, a global window.SanitizeIDValue would be sufficient. The callback function must reside under the window object:

foundation.custom.js

// The value of the data parameter is equal to the property bag of the current widget
function SanitizeIDValue(data) {
    if (data.id && data.id !== '') {
        data.id = data.id.replace(/=/g, '').replace(/-/g, '');
    }
    return data;
}

Once the function has been created in the appropriate file, simply set the callbackMethod property on the widget. Following this example, let's continue with the idea that we need to add jQuery click events to a button rendered by this widget. We need to add the event to the button before it is clickable by the user to prevent any odd behavior. The uiCallbackMethod property is perfect to handle this scenario as the elements are available in the DOM but not yet rendered. Let's create a new function for this:

foundation.custom.js

// control = jquery selector of widget container
// properties = property bag of the widget
function MyWidgetClickEvent(control, properties) {
    if (control && control.length > 0) {
        $(control[0]).find(properties.publishButtonId).unbind().bind('click', function(event) {
            alert('Your item will be processed shortly...');
        });
    }
}

Similar to callbackMethod, simply set the property for uiCallbackMethod and the function will be invoked pre-render.

Widget Implementation

callbackMethod

The following widgets support the callbackMethod property by default:

  • AnnouncementItemsWidget
  • BannerWidget
  • CalendarWidget
  • CollatedDepartmentNewsWidget
  • CompanyCalendarWidget
  • CompanyNewsHeroWidget
  • CompanyNewsItemWidget
  • CompanyNewsListWidget
  • DashboardContainerWidget
  • DepartmentListWidget
  • DepartmentNewsItemWidget
  • DepartmentNewsListWidget
  • DepartmentNewsWidget
  • DocumentFilterWidget
  • DocumentListWidget
  • DocumentsSummaryListWidget
  • DocumentViewerRefinerWidget
  • DocumentViewerTreeWidget
  • DocumentViewerWidget
  • EmployeeDetailWidget
  • EventDetailWidget
  • FaqWidget
  • FormWidget
  • GenericItemWidget
  • GenericListWidget
  • GenericSearchListWidget
  • ImportantDatesWidget
  • LanguagePickerWidget
  • LatestMediaWidget
  • MyAppsWidget
  • MyFavoritesWidget
  • MyFormsWidget
  • MyTeamWidget
  • PeopleDirectoryWidget
  • QuickLinksWidget
  • RssNewsWidget
  • SiteAlertsWidget
  • StepperInstanceWidget
  • TrafficWidget
  • TrayWidget
  • WeatherWidget

The functionality for invoking the custom callback function is standardized across widgets. Typescript example below:

BindTemplate(templateUri: string, data: any, targetDiv: string) {
    var hadError = false;
    var theDataCallBack = (<any>window)[_cur.myWidget.callbackMethod];
    if (typeof theDataCallBack == "function") {
        try {
            data = theDataCallBack(data);
        } catch (e) {
            Akumina.AddIn.Logger.WriteErrorLog(_cur.myWidget.callbackMethod + " had an error: " + e);
            hadError = true;
            var errorObj = { targetDiv: _cur.myWidget.SenderId, sender: _cur.myWidget.SenderId, message: e, properties: _cur.myWidget };
            new (<any>window).Akumina.Digispace.AppPart.Data().Templates.BindErrorTemplateForWidgets(errorObj);
        }
    }

    if (!hadError) {
        // Bind and parse template...
    }
}

uiCallbackMethod

The following widgets support the uiCallbackMethod by default:

  • AnnouncementItemsWidget
  • BannerWidget
  • CalendarWidget
  • CollatedDepartmentNewsWidget
  • CompanyCalendarWidget
  • CompanyNewsHeroWidget
  • CompanyNewsItemWidget
  • CompanyNewsListWidget
  • ContentBlockWidget
  • DepartmentListWidget
  • DepartmentNewsItemWidget
  • DepartmentNewsWidget
  • DocumentFilterWidget
  • DocumentListWidget
  • DocumentsSummaryListWidget
  • EmployeeDetailWidget
  • EventDetailWidget
  • FaqWidget
  • FormWidget
  • GenericListWidget
  • GenericSearchListWidget
  • ImportantDatesWidget
  • LanguagePickerWidget
  • LatestMediaWidget
  • MyAppsWidget
  • MyFavoritesWidget
  • MyFormsWidget
  • MyTeamWidget
  • PeopleDirectoryWidget
  • QuickLinksWidget
  • RssNewsWidget
  • SiteAlertsWidget
  • StepperInstanceWidget
  • TrafficWidget
  • TrayWidget
  • WeatherWidget
  • WorkspaceDetailsWidget
  • WorkspaceDocumentsViewWidget
  • WorkspaceDocumentsWidget
  • WorkspaceListingFeaturedWidget
  • WorkspaceListingWidget
  • WorkspaceManageMembersWidget
  • WorkspaceMilestoneWidget
  • WorkspaceRecentConversationsWidget
  • WorkspaceTabWidget

The functionality for invoking the custom callback function is standardized across widgets. Typescript example below:

BindTemplate(templateUri: string, data: any, targetDiv: string) {
    var hadError = false;
    
    // callbackMethod functionality...

    if (!hadError) {
        new Akumina.Digispace.AppPart.Data().Templates.ParseTemplate(templateUri, data).then(function (html) {
            // UI parsing/rendering logic...

            _cur.BindUI(control, _cur.myWidgetRequest);
        });
    }
}

BindUI(control: JQuery, properties: any) {
    var theCallBack = (<any>window)[_cur.myWidget.uiCallbackMethod];
    if (typeof theCallBack == "function") {
        theCallBack(control, properties);
    }
}
← Akumina React WidgetsRenderChildWidgets →
  • Natively Supported Callbacks
  • Widget Implementation
Akumina Developer Documentation
Docs
Akumina Framework 5.0Akumina Widget BuilderAkumina Yeoman GeneratorSite Deployer
Community
Akumina Community Site
More
GitHubStar
Copyright © 2024 Akumina