B4J Tutorial [BANanoWebix] Lesson 17 - Comments / Chat Widget


The comments widget works like a chat screen. Now I need to learn BANanoWebsockets and feed that into this.


One of the nice things about this component is that the users data, the comments can be hosted and fed directly from any source type of data. For example in our example, we have saved everything in a JS file and added this to our project with BANano.Header.AddJavascriptFile


This data file has 'var' definitions for the various arrays we need for this example.


As these are global variables, what we did was to have javascript functions defined to be able to return the contents of the arrays.

#if javascript
    function getUsers(){
        return usersData;
    function getComments(){
        return commentsData;
#End If

In Row 1 we have added our toolbar, so we create a new row and insert our WixComment element there. As you will note, there is nothing much to set here.

As the current user, .SetCurrentUser(?) is needed to ensure that you are easily identified. Each user can have a status set to indicate online activity.

Dim R2 As WixRow
    Dim ud As List = BANano.RunJavascriptMethod("getUsers",Null)
    Dim cd As List = BANano.RunJavascriptMethod("getComments", Null)
    Dim comments As WixComments

We run the JS methods to get the variable details for the users and comments and then assign them to the widget.

These are the constants for the users for the 'status' key from the list of users. For this example, this was not included.

Public USER_ACTIVE As String = "active"
    Public USER_AWAY As String = "away"
    Public USER_BUSY As String = "busy"
    Public USER_NONE As String = "none"

There are more functions for this to load more comments etc, and one to trap the various events like sending and retrieving the comments and loading them.