BBjEnterpriseNamespace::setCallbackForNamespaceChange

Description

In BBj 13.0 and higher, this method sets a callback that will be called if any Named Object within this BBjEnterpriseNamespace is changed.

Syntax

Return Value

Method

void

setCallbackForNamespaceChange(string callbackName)

void

setCallbackForNamespaceChange(UserObject userObj, string methodName)

Parameters

Variable

Description

callbackName

Specifies the name of the callback.

methodName

Specifies the method of userObj which is to be called.

userObj

Specifies a UserObject that has a method which is to be called when value changes.

Return Value

None.

Remarks

All callbacks that a program registered on a BBjEnterpriseNamespace are removed when that program executes START, STOP, END, or BEGIN. All callbacks registered by a BBj process are removed when the BBj process terminates.

rem host and authentication information
host$="localhost"
port=2552
user$="admin"
password$="admin123"

sysgui! = bbjapi().openSysGui("X0")
window! = sysgui!.addWindow(200,200,200,100,"Enterprise NS",$02$)

namespace! =
bbjapi().getBBjEnterpriseNamespace(host$,port,"test",user$,password$)

REM set a callback that will be called if *any* value in namespace changes
namespace!.setCallbackForNamespaceChange("someValueChanged")

REM set a callback that will be called if the value changes
namespace!.setCallbackForVariableChange("x","xChanged")

REM set a callback that will be called if *any* value is
REM set (even if the value is not changed)
namespace!.setCallbackForNamespace("someValueSet")

REM set a callback that will be called if the value of x is set
REM (even if the values is not changed)
namespace!.setCallbackForVariable("x","xSet")

window!.setCallback(BBjWindow.ON_CLOSE,"OnClose")

process_events

OnClose:
REM  disable all callbacks
namespace!.enableCallbacks(0)
REM  and re-enable them
namespace!.enableCallbacks(1)

REM remove all callbacks
namespace!.removeCallbackForNamespace()
namespace!.removeCallbackForNamespaceChange()
namespace!.removeCallbackForVariableChange()
namespace!.removeCallbackForVariable()
release

someValueChanged:
x=MsgBox("some value in " + namespace!.getName() + " has changed")
return

someValueSet:
x=MsgBox("some value in " + namespace!.getName() + " has been set")
return

xChanged:
x=MsgBox("the value of x in " + namespace!.getName() + " has changed")
return

xSet:
x=MsgBox("the value of x in " + namespace!.getName() + " has been set")
return

See Also

BBjAPI

BBjEnterpriseNamespace

BBjNamespace

Object Variables

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.