BBjWindowValues

Creation Path

BBjAPI > BBjSysGui > BBjWindow > BBjTopLevelWindow > BBjWindowValues

Description

In BBj 17.00 and higher, the BBjWindowValues object returns the values of all simple controls on a given BBjTopLevelWindow in a single operation, minimizing network overhead across distributed client/server connections. Complex controls containing multiple values (like grids) are not included in this data structure.

Creation

A BBjWindowValues object is created through the following BBjTopLevelWindow method:

Return Value Method
BBjWindowValues getValues()

Methods of BBjWindowValues

Return Value Method
HashMap<Integer, HashMap<Integer, String>> getMap()
int getSelectedIndex(BBjListBox control!)
int getSelectedIndex(BBjListButton control!)
int getSelectedIndex(BBjListEdit control!)
String getText(BBjControl control!)
BBjNumber getValue(BBjInputD control!)
BBjNumber getValue(BBjInputN control!)
BBjNumber getValue(BBjInputT control!)
BBjNumber getValue(BBjSlider control!)
boolean isSelected(BBjCheckBox control!)
boolean isSelected(BBjRadioButton control!)

Example

rem ' BBjTopLevelWindow::getValues
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
title$ = "BBjTopLevelWindow::getValues"
window! = sysgui!.addWindow(50,50,340,325,title$,$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj"); rem ' just terminate
window!.setCallback(window!.ON_CLOSE,"close"); rem ' report values
menubar! = window!.addMenuBar()
menu! = menubar!.addMenu(-100,"&File")
titem! = menu!.addMenuItem(-101,"get&Text")
titem!.setCallback(titem!.ON_MENU_ITEM_SELECT,"getText")
vitem! = menu!.addMenuItem(-102,"get&Values")
vitem!.setCallback(vitem!.ON_MENU_ITEM_SELECT,"getValues")
exit! = menu!.addMenuItem(-103,"E&xit")
exit!.setCallback(exit!.ON_MENU_ITEM_SELECT,"eoj")
list$="";for i=asc("A") to asc("Z");list$=list$+chr(i)+$0a$;next i
gosub init; rem ' temp file + recordset
fast_touch_click$ = stbl("!OPTIONS","FAST_TOUCH_CLICK=TRUE")
navigator! = window!.addNavigator(100,10,10,320,25,"Navigator",$$)
navigator!.setToolTipText("BBjNavigator")
navigator!.bindRecordSet(recordset!,"key")
navigator!.setCallback(navigator!.ON_NAV_FIRST,"nav_first")
navigator!.setCallback(navigator!.ON_NAV_PREVIOUS,"nav_previous")
navigator!.setCallback(navigator!.ON_NAV_NEXT,"nav_next")
navigator!.setCallback(navigator!.ON_NAV_LAST,"nav_last")
listbox! = window!.addListBox(101,10,45,100,60,list$,$$)
listbox!.setToolTipText("BBjListBox")
listbox!.bindRecordSet(recordset!,"listbox")
listbutton! = window!.addListButton(102,120,45,100,160,list$,$$)
listbutton!.setToolTipText("BBjListButton")
listbutton!.bindRecordSet(recordset!,"listbutton")
listedit! = window!.addListEdit(103,230,45,100,160,list$,$$)
listedit!.setToolTipText("BBjListEdit")
listedit!.bindRecordSet(recordset!,"listedit")
editbox! = window!.addEditBox(104,120,80,100,25,"",$$)
editbox!.setToolTipText("BBjEditBox")
editbox!.bindRecordSet(recordset!,"editbox")
password! = window!.addEditBox(105,230,80,100,25,"",$0400$)
password!.setToolTipText("BBjEditBox (Password)")
password!.bindRecordSet(recordset!,"password")
cedit! = window!.addCEdit(106,10,115,100,60,"",$8106$)
cedit!.setToolTipText("BBjCEdit")
cedit!.bindRecordSet(recordset!,"cedit")
text! = window!.addStaticText(107,10,185,100,25,"",$$)
text!.setToolTipText("BBjStaticText")
text!.bindRecordSet(recordset!,"text")
inpute! = window!.addInputE(108,120,115,100,25,$$,"XXXX-XXXX-XXXX-XXXX")
inpute!.setToolTipText("BBjInputE")
inpute!.bindRecordSet(recordset!,"inpute")
inputn! = window!.addInputN(109,120,150,100,25,$$,"$###,###,###.00-")
inputn!.setToolTipText("BBjInputN")
inputn!.bindRecordSet(recordset!,"inputn")
inputd! = window!.addInputD(110,120,185,100,25)
inputd!.setToolTipText("BBjInputD")
inputd!.bindRecordSet(recordset!,"inputd")
checkbox! = window!.addCheckBox(111,230,115,100,25,"CheckBox",$$)
checkbox!.setToolTipText("BBjCheckBox")
checkbox!.bindRecordSet(recordset!,"checkbox")
radio1! = window!.addRadioButton(112,230,150,100,25,"Radio1",$$)
radio1!.setToolTipText("BBjRadioButton")
radio1!.bindRecordSet(recordset!,"radio1")
radio1!.setCallback(radio1!.ON_CHECK_ON,"check")
radio1!.setCallback(radio1!.ON_CHECK_OFF,"check")
radio2! = window!.addRadioButton(113,230,185,100,25,"Radio2",$$)
radio2!.setToolTipText("BBjRadioButton")
radio2!.bindRecordSet(recordset!,"radio2")
radio2!.setCallback(radio2!.ON_CHECK_ON,"check")
radio2!.setCallback(radio2!.ON_CHECK_OFF,"check")
slider! = window!.addHorizontalSlider(114,10,220,320,50)
slider!.setMajorTickSpacing(10)
slider!.setMinorTickSpacing(5)
slider!.setPaintTicks(1)
slider!.setPaintLabels(1)
slider!.setToolTipText("BBjSlider")
slider!.bindRecordSet(recordset!,"slider")
form! = window!.addButton(1,10,285,125,25,"FormValidation",$$)
form!.setCallback(form!.ON_BUTTON_PUSH,"form")
form!.setCallback(form!.ON_FORM_VALIDATION,"formvalidation")
getValues! = window!.addButton(2,140,285,95,25,"getValues",$$)
getValues!.setCallback(getValues!.ON_BUTTON_PUSH,"getValues")
getText! = window!.addButton(3,240,285,90,25,"getText",$$)
getText!.setCallback(getText!.ON_BUTTON_PUSH,"getText")
radiogroup! = window!.addRadioGroup()
radiogroup!.add(radio1!)
radiogroup!.add(radio2!)
print recordset!.getCurrentRecordData()
for id = 101 to 114
  window!.getControl(id).setCallback(window!.ON_LOST_FOCUS,"blur",err=*next)
next id
process_events
close:
  event! = sysgui!.getLastEvent()
  ms = System.currentTimeMillis()
  allValues! = event!.getValues()
  winValues! = allValues!.get(new Integer(window!.getContextID()))
  html! = new StringBuilder("<html>")
  dim text$[101:114]
  for id = 101 to 114
    text$[id] = str(winValues!.get(new Integer(id)))
  next id
  ms = System.currentTimeMillis() - ms
  title$ = event!.getEventName() + " getValues (14 controls)"
  for id = 101 to 114
    control! = window!.getControl(id)
    control$ = control!.getToolTipText()
    html!.append(control$).append(" ").append(str(id)).append(" = ")
    html!.append("""").append(cvs(text$[id],16)).append("""").append("<br>")
  next id 
  a = msgbox(html!.toString(),0,title$) 
eoj:
  rem ' gosub dirty
  recordset!.close()
  erase filename$
  release
init:
mkdir "./files",err=*next
filename$ = "./files/navigator"+str(dec(info(3,0)))+".dat"
erase filename$,err=*next
vkeyed filename$,[0:1:4],0,1024
temp = unt
open (temp)filename$
template$ = "key:c(4),slider:n(3*),listbox:c(1*),listbutton:c(1*),listedit:c(1*),"
template$ = template$ + "radio1:n(1*),radio2:n(1*),checkbox:n(1*),inputn:n(9*),"
template$ = template$ + "inputd:n(7*),text:c(10*),editbox:c(10*),password:c(10*),"
template$ = template$ + "inpute:c(10*),cedit:c(99*=)"
dim rec$:template$
for rec = 1 to 100
   rec.key$ = str(rec*10:"0000"); rem str(rnd(9999):"0000")
   rec.slider = rnd(100)
   rec.listbox$ = chr(asc("A")+rnd(26))
   rec.listbutton$ = chr(asc("A")+rnd(26))
   rec.listedit$ = chr(asc("A")+rnd(26))
   rec.radio2 = mod(rec,2)
   rec.radio1 = !(rec.radio2)
   rec.checkbox = rnd(2)
   rec.inputn = rnd(0) * 9999999
   rec.inputd = rnd(1000) + jul(0,0,0) - 500
   gosub text; rec.text$ = text$
   gosub text; rec.editbox$ = text$
   gosub text; rec.password$ = text$
   gosub text; rec.inpute$ = text$
   rec.cedit$ = ""
   for x = 0 to rnd(16);gosub text;rec.cedit$=rec.cedit$+text$+" ";next x
   writerecord(temp)rec$
next rec
close (temp)
recordset! = bbjapi().createFileRecordSet(filename$,"",fattr(rec$))
return
text:
   text$ = ""
   for i = 1 to rnd(16)
       text$ = text$ + chr(asc("a")+rnd(26))
    next i
   return
return
check:
   event! = sysgui!.getLastEvent()
   control! = event!.getControl()
   print control!," ",event!
return
nav_first:
   gosub dirty
   recordset!.first(err=*next)
   print recordset!.getCurrentRecordData()
return
nav_previous:
   gosub dirty
   recordset!.previous(err=*next)
   print recordset!.getCurrentRecordData()
return
nav_next:
   gosub dirty
   recordset!.next(err=*next)
   print recordset!.getCurrentRecordData()
return
nav_last:
   gosub dirty
   recordset!.last(err=*next)
   print recordset!.getCurrentRecordData()
return
dirty:
  if recordset!.isCurrentRecordDirty() then
   print recordset!.getCurrentRecordData()
   i = msgbox("Save record?",4+32+256,"Record Changed")
   if i = 6 then
      recordset!.update(recordset!.getCurrentRecordData())
   endif
  endif
return
form:
  event! = sysgui!.getLastEvent()
  print event!.getEventName()
return
getText:
  html! = new StringBuilder("<html>")
  dim text$[101:114]
  ms = System.currentTimeMillis()
  text$[101] = window!.getControl(101).getText()
  text$[102] = window!.getControl(102).getText()
  text$[103] = window!.getControl(103).getText()
  text$[104] = window!.getControl(104).getText()
  text$[105] = window!.getControl(105).getText()
  text$[106] = window!.getControl(106).getText()
  text$[107] = window!.getControl(107).getText()
  text$[108] = window!.getControl(108).getText()
  text$[109] = window!.getControl(109).getText()
  text$[110] = str(window!.getControl(110).getValue())
  text$[111] = str(window!.getControl(111).isSelected())
  text$[112] = str(window!.getControl(112).isSelected())
  text$[113] = str(window!.getControl(113).isSelected())
  text$[114] = str(window!.getControl(114).getValue())
  ms = System.currentTimeMillis() - ms
  title$ = str(ms) + " msec for getText (14 controls)"
  for id = 101 to 114
    control! = window!.getControl(id)
    control$ = control!.toString()
    control$ = control$(1,pos("@"=control$)-1)
    html!.append(control$).append(" ").append(str(id)).append(" = ")
    html!.append("""").append(cvs(text$[id],16)).append("""").append("<br>")
  next id
  a = msgbox(html!.toString(),0,title$)
return
formvalidation:
  event! = sysgui!.getLastEvent()
  event$ = event!.getEventName()
  html! = new StringBuilder("<html>")
  dim text$[101:114]
  ms = System.currentTimeMillis()
  for id = 101 to 114
    text$[id] = event!.getText(window!.getControl(id))
  next id
  event!.accept(event!.isSelected(checkbox!))
  ms = System.currentTimeMillis() - ms
  title$ = str(ms) + " msec for " + event$ + " (14 controls)"
  for id = 101 to 114
    control! = window!.getControl(id)
    control$ = control!.toString()
    control$ = control$(1,pos("@"=control$)-1)
    html!.append(control$).append(" ").append(str(id)).append(" = ")
    html!.append("""").append(cvs(text$[id],16)).append("""").append("<br>")
  next id
  a = msgbox(html!.toString(),0,title$)
return
getValues:
  ms = System.currentTimeMillis()
  values! = window!.getValues()
  map! = values!.getMap()
  html! = new StringBuilder("<html>")
  dim text$[101:114]
  for id = 101 to 114
    text$[id] = values!.getText(window!.getControl(id))
  next id
  ms = System.currentTimeMillis() - ms
  title$ = str(ms) + " msec for getValues (14 controls)"
  for id = 101 to 114
    control! = window!.getControl(id)
    control$ = control!.getToolTipText()
    html!.append(control$).append(" ").append(str(id)).append(" = ")
    html!.append("""").append(cvs(text$[id],16)).append("""").append("<br>")
  next id
  a = msgbox(html!.toString(),0,title$)
return
blur:
  event! = sysgui!.getLastEvent()
  print event!.getEventName()," ",event!.getText()," ",event!.isTemporary()
return

See Also

BBjCloseEvent

BBjFormValidationEvent

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