
BBjBuiManager / BBjWebManager
Description
In BBj 14.0 and higher, the BBjBuiManager object provides an interface to BUI and DWC application runtime settings.
In BBj 22.03 and higher, BBjWebManager is an alias for BBjBuiManager.
Creation
BBjAPI > BBjBuiManager
BBjAPI > BBjWebManager
The BBjBuiManager object is created through the following BBjAPI methods:
Return Value |
Method |
---|---|
BBjBuiManager |
|
BBjWebManager |
Methods of BBjBuiManager
Return Value |
Method |
---|---|
appAction(string p_app) |
|
void |
clearCallback(int eventType) |
int | executeAsyncScript(string script) |
Object | executeScript(string script) |
string |
|
string |
getAttribute(string attribute) getAttribute(string attribute, string selector) |
string | getDarkTheme() |
string | getLightTheme() |
boolean |
|
string | getTheme() |
string |
getTitle() |
string |
getUrl() |
void |
injectLinkUrl(string url) injectLinkUrl(string url, boolean top) injectLinkUrl(string url, boolean top, String attributes) injectLinkUrl(string url, boolean top, HashMap attributes) |
void |
injectScript(string script) injectScript(string script, boolean top) injectScript(string script, boolean top, String attributes) injectScript(string script, boolean top, HashMap attributes) |
void |
injectScriptUrl(string url) injectScriptUrl(string url, boolean top) injectScriptUrl(string url, boolean top, String attributes) injectScriptUrl(string url, boolean top, HashMap attributes) |
void |
injectStyle(string style) injectStyle(string style, boolean top) injectStyle(string style, boolean top, String attributes) injectStyle(string style, boolean top, HashMap attributes) |
void |
injectStyleUrl(string url) injectStyleUrl(string url, boolean top) injectStyleUrl(string url, boolean top, String attributes) injectStyleUrl(string url, boolean top, HashMap attributes) |
boolean |
|
msgAction(string msg) |
|
void |
setAttribute(string attribute, string value) setAttribute(string attribute, string value, string selector) |
void | setDarkTheme(string darkTheme) |
void | setLightTheme(string lightTheme) |
void |
setMeta(string name, string content) setMeta(string name, string content, string attributes) |
void |
setCallback(int eventType, CustomObject customObject, string method) setCallback(int eventType, string callback) |
void |
setEndAction(BBjBuiCloseAction action) |
void |
setErrAction(BBjBuiCloseAction action) |
void |
setShowConfirmCloseDialog(boolean showConfirmCloseDialog) |
void | setTheme(string theme) |
void |
setTitle(string title) |
urlAction(string p_url) |
Events
Callback Code |
Object-Oriented Event |
Read Record Event |
Code |
---|---|---|---|
ON_BROWSER_BACK |
N/A |
N/A |
|
ON_BROWSER_CLOSE | BBjBrowserCloseEvent | N/A | N/A |
ON_EXECUTE_SCRIPT | BBjExecuteScriptEvent | N/A | N/A |
ON_LINK_FAILED | BBjLinkFailedEvent | N/A | N/A |
ON_LINK_LOADED | BBjLinkLoadedEvent | N/A | N/A |
ON_SCRIPT_FAILED | BBjScriptFailedEvent | N/A | N/A |
ON_SCRIPT_LOADED | BBjScriptLoadedEvent | N/A | N/A |
The BBjBrowserBackEvent is available when the BUI app is configured to manage the browser history.
In BBj 21.02 and higher, the BBjBrowserCloseEvent indicates that the browser client has unexpectedly disconnected.
In BBj 22.03 and higher, the BBjScriptLoadedEvent and BBjScriptFailedEvent report the success or failure of injectScriptUrl.
In BBj 22.03 and higher, the BBjLinkLoadedEvent and BBjLinkFailedEvent report the success or failure of injectLinkUrl and injectStyleUrl. These events are reliably reported for stylesheets, but may not be reported for other kinds of links.
In BBj 22.14 and higher, the BBjExecuteScriptEvent reports the result of a script invoked with executeAsyncScript.
Remarks
None.
Constants
None.
Example
BBjBuiManager Example
rem ' BBjBuiManager
declare BBjSysGui sysgui!
declare BBjBuiManager bui!
declare BBjBusyIndicator busy!
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
bui! = bbjapi().getBuiManager()
bui!.setCallback(bui!.ON_BROWSER_CLOSE,"ON_BROWSER_CLOSE",err=*next)
bbjapi().getConfig().releaseOnLostConnection(0)
setesc ON_LOST_CONNECTION
url$ = "(Not BUI)"
url$ = bui!.getUrl(err=*next)
appName$ = " (Not BUI)"
appName$ = bui!.getApplicationName(err=*next)
title$ = "BBjBuiManager: " + appName$
touch = 0
touch = bui!.isTouchSupported(err=*next)
if touch then title$ = title$ + " (Touch)" else title$ = title$ + " (Not Touch)"
window! = sysgui!.addWindow(25,25,450,600,title$,$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")
status! = window!.addStatusBar(999)
window!.addStaticText(99,25,25,400,25,"URL: "+url$,$$)
window!.addGroupBox(100,25,75,400,125,"End Actions")
endApp! = window!.addRadioButton(101,30,100,75,25,"App",$0020$)
endUrl! = window!.addRadioButton(102,105,100,75,25,"URL",$0020$)
endMsg! = window!.addRadioButton(103,180,100,75,25,"Msg",$0020$)
endNone! = window!.addRadioButton(104,255,100,75,25,"None",$0020$)
endDefault! = window!.addRadioButton(105,330,100,75,25,"Default",$0020$)
endGroup! = window!.addRadioGroup()
endGroup!.add(endApp!)
endGroup!.add(endUrl!)
endGroup!.add(endMsg!)
endGroup!.add(endNone!)
endGroup!.add(endDefault!)
window!.addStaticText(106,30,150,60,25,"Value:",$8000$)
endValue! = window!.addEditBox(107,100,150,225,25,$$)
setEndAction! = window!.addButton(108,340,150,75,25,"Set",$$)
setEndAction!.setCallback(setEndAction!.ON_BUTTON_PUSH,"setEndAction")
window!.addGroupBox(200,25,225,400,125,"Err Actions")
errApp! = window!.addRadioButton(201,30,250,75,25,"App",$0020$)
errUrl! = window!.addRadioButton(202,105,250,75,25,"URL",$0020$)
errMsg! = window!.addRadioButton(203,180,250,75,25,"Msg",$0020$)
errNone! = window!.addRadioButton(204,255,250,75,25,"None",$0020$)
errDefault! = window!.addRadioButton(205,330,250,75,25,"Default",$0020$)
errGroup! = window!.addRadioGroup()
errGroup!.add(errApp!)
errGroup!.add(errUrl!)
errGroup!.add(errMsg!)
errGroup!.add(errNone!)
errGroup!.add(errDefault!)
window!.addStaticText(206,30,300,60,25,"Value:",$8000$)
errValue! = window!.addEditBox(207,100,300,225,25,$$)
setErrAction! = window!.addButton(208,340,300,75,25,"Set",$$)
setErrAction!.setCallback(setEndAction!.ON_BUTTON_PUSH,"setErrAction")
title$ = "Show Confirm Close Dialog"
confirm = 0
confirm = bui!.getShowConfirmCloseDialog(err=*next)
flags$ = iff(confirm,$0004$,$0000$)
setShowConfirmDialog! = window!.addCheckBox(209,25,375,300,25,title$,flags$)
setShowConfirmDialog!.setCallback(setShowConfirmDialog!.ON_CHECK_ON,"showConfirmDialogOn")
setShowConfirmDialog!.setCallback(setShowConfirmDialog!.ON_CHECK_OFF,"showConfirmDialogOff")
showBusy! = window!.addButton(1,25,425,100,25,"Busy",$$)
showBusy!.setCallback(showBusy!.ON_BUTTON_PUSH,"showBusy")
busyMessage! = window!.addEditBox(300,150,425,275,25,"Working...",$$)
gosub fetch
rem ' https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
js$ = "function toISOString(date){try{return new Date(date).toISOString()}catch(e){return new String(e)}}"
sysgui!.injectScript(js$)
toISOString! = window!.addButton(2,25,475,100,25,"toISOString",$$)
toISOString!.setCallback(toISOString!.ON_BUTTON_PUSH,"toISOString")
text$ = "December 25, " + date(0:"%Yl")
text! = window!.addEditBox(400,150,475,275,25,text$,$$)
bui!.setCallback(bui!.ON_EXECUTE_SCRIPT,"executeScript",err=*next)
executeAsyncScript! = window!.addButton(3,150,525,275,25,"executeAsyncScript",$$)
executeAsyncScript!.setCallback(executeAsyncScript!.ON_BUTTON_PUSH,"samples")
process_events
eoj:
release
toISOString:
text$ = text!.getText()
js$ = "toISOString('"+text$+"')"
t = tim
if info(3,6)="5" or info(3,6)="6" then
ISOString! = bui!.executeScript(js$)
else
ISOString! = sysgui!.executeScript(js$)
endif
t = tim - t, t = t * 3600 * 1000
msg$ = "executeScript " + js$ + " = " + str(ISOString!) + ": " + str(t) + " milliseconds."
status!.setText(msg$)
return
samples:
if web then body$ = "" else body$ = "document.body."
js$ = "console.log('executeAsyncScript')"; gosub executeAsyncScript; rem ' undefined
js$ = "Math.sqrt(100)"; gosub executeAsyncScript; rem ' Double or Integer 10
js$ = "Math.sqrt(-1)"; gosub executeAsyncScript; rem ' Double NaN
js$ = "null"; gosub executeAsyncScript; rem ' null
js$ = "undefined"; gosub executeAsyncScript; rem ' null
js$ = "document.hasFocus()"; gosub executeAsyncScript; rem ' Boolean false
js$ = body$ + "style.backgroundColor"; gosub executeAsyncScript; rem ' String #ffff00
js$ = "Math.PI"; gosub executeAsyncScript; rem ' Double 3.141592653589793
js$ = "1/0"; gosub executeAsyncScript; rem ' Double Infinity
js$ = "-1/0"; gosub executeAsyncScript; rem ' Double -Infinity
js$ = "Number.MIN_SAFE_INTEGER"; gosub executeAsyncScript; rem '
js$ = "Number.MAX_SAFE_INTEGER"; gosub executeAsyncScript; rem '
js$ = "Number.MAX_VALUE"; gosub executeAsyncScript; rem '
js$ = "0"; gosub executeAsyncScript; rem ' Integer
js$ = "42"; gosub executeAsyncScript; rem ' Integer
js$ = "2147483647"; gosub executeAsyncScript; rem ' Integer
js$ = "2147483648"; gosub executeAsyncScript; rem ' Long
js$ = """true"""; gosub executeAsyncScript; rem ' String
js$ = """false"""; gosub executeAsyncScript; rem ' String
js$ = """0"""; gosub executeAsyncScript; rem ' String
js$ = """1"""; gosub executeAsyncScript; rem ' String
js$ = """null"""; gosub executeAsyncScript; rem ' String
js$ = "null"; gosub executeAsyncScript; rem ' null
js$ = "undefined"; gosub executeAsyncScript; rem ' null
return
executeAsyncScript:
t = tim
if info(3,6)="5" or info(3,6)="6" then
index! = bui!.executeAsyncScript(js$)
else
index! = sysgui!.executeAsyncScript(js$)
endif
index = 0; if index!<>null() then index = num(index!)
t = tim - t, t = t * 3600 * 1000
System.err.println("executeAsyncScript " + str(index) + " " + js$ + ": " + str(t) + " milliseconds.")
return
executeScript:
event! = sysgui!.getLastEvent()
index = 0, index = event!.getIndex(err=*next)
result! = event!.getResult()
if result! = null() then result$ = "null" else result$ = result!.getClass().getName()+" "+result!.toString()
msg$ = event!.getEventName()+" "+str(index)+" "+date(0:"%Hz:%mz:%sz.%tz %p")
msg$ = msg$ + " result = " + result$ + " script = " + event!.getScript()
print msg$
System.err.println(msg$)
i = msgbox(msg$,0,event!.getEventName())
return
fetch:
endAction! = bui!.getEndAction(err=*return)
switch endAction!.getActionType()
case endAction!.ACTION_APP
endApp!.setSelected(1)
endValue!.setText(endAction!.getAppName())
break
case endAction!.ACTION_URL
endUrl!.setSelected(1)
endValue!.setText(endAction!.getUrl())
break
case endAction!.ACTION_MSG
endMsg!.setSelected(1)
endValue!.setText(endAction!.getMessage())
break
case endAction!.ACTION_NONE
endNone!.setSelected(1)
endValue!.setText("")
break
case endAction!.ACTION_DEFAULT
endDefault!.setSelected(1)
endValue!.setText("")
break
swend
errAction! = bui!.getErrAction(err=*return)
switch errAction!.getActionType()
case errAction!.ACTION_APP
errApp!.setSelected(1)
errValue!.setText(errAction!.getAppName())
break
case errAction!.ACTION_URL
errUrl!.setSelected(1)
errValue!.setText(errAction!.getUrl())
break
case errAction!.ACTION_MSG
errMsg!.setSelected(1)
errValue!.setText(errAction!.getMessage())
break
case errAction!.ACTION_NONE
errNone!.setSelected(1)
errValue!.setText("")
break
case errAction!.ACTION_DEFAULT
errDefault!.setSelected(1)
errValue!.setText("")
break
swend
return
setEndAction:
if endApp!.isSelected() then action! = bui!.appAction(endValue!.getText())
if endUrl!.isSelected() then action! = bui!.urlAction(endValue!.getText())
if endMsg!.isSelected() then action! = bui!.msgAction(endValue!.getText())
if endNone!.isSelected() then action! = bui!.noneAction()
if endDefault!.isSelected() then action! = bui!.defaultAction()
bui!.setEndAction(action!,err=*return)
return
setErrAction:
if errApp!.isSelected() then action! = bui!.appAction(errValue!.getText())
if errUrl!.isSelected() then action! = bui!.urlAction(errValue!.getText())
if errMsg!.isSelected() then action! = bui!.msgAction(errValue!.getText())
if errNone!.isSelected() then action! = bui!.noneAction()
if errDefault!.isSelected() then action! = bui!.defaultAction()
bui!.setErrAction(action!,err=*return)
return
showConfirmDialogOn:
bui!.setShowConfirmCloseDialog(1,err=*next)
return
showConfirmDialogOff:
bui!.setShowConfirmCloseDialog(0,err=*next)
return
showBusy:
busy! = bui!.getBusyIndicator(err=*return)
rem ' BBjBusyIndicator::setAttribute BBj 22.02+ DWC
busy!.setAttribute("spinner-clockwise","false",err=*next)
busy!.setAttribute("spinner-speed","2000",err=*next)
busy!.setAttribute("spinner-expanse","3xl",err=*next)
busy!.setAttribute("spinner-theme","info",err=*next)
busy!.setText(busyMessage!.getText())
busy!.setVisible(1)
wait 3
busy!.setVisible(0)
return
on_lost_connection:
event$ = "ON_LOST_CONNECTION"
goto terminate
on_browser_close:
event$ = "ON_BROWSER_CLOSE"
goto terminate
terminate:
seterr release
System.err.println(pgm(-2)+" "+event$+" "+str(tcb(19)))
filename$ = System.getProperty("user.home") + "/Desktop/" + event$ + ".txt"
u = unt
open (u,mode="o_create,o_trunk")filename$
print (u)date(0:"%Hz:%mz:%sz.%tz ")+event$+" "+str(tcb(19))
close (u)
release:
release -1
See Also
BBjConfig::releaseOnLostConnection
See the BBj Object Diagram for an illustration of the relationship between BBj Objects.