Title: The PUG Challenge
1- The PUG Challenge -
- Brynjar Hasle, Chemistry as
- www.chemistry.no
- Geir O. Olsen, THInc Consulting as
2Case PUG member system
3Datamodel
4Tools
- - Dynamic 4GL constructs
- 9.1d/10.0a AppServer (stateless)
- Aia client on webserver
- - Progress 8.x - 9.1/10.0a RDBMS
5Basic Elements
Client
x.w
y.w
UI_lib.p
z.w
AS_lib.p
Server
- Get data-gettemptablejoin.p
- -getfieldlist.p
- getfieldvalues.p (FIND)
- -gettemptable (input ltfillgt.p)-checkcurrentchange
d.p
Put data-servertrans.p
6Server, get data
- - gettemptablejoin.pInput - Buffers and
fields - Query criteria - Startrow and
number of rows to return - Hooks for calculated fields (input .ps for
logic) - Returns temp-table handle (and hence the data)
- getfieldlist.pInput - Buffers and fields
- Query criteriaReturns fieldlist (f.ex to
populate drop-down) - - gettemptable.p (input .p, output temp-table
handle)
7Server, put data
- Trans.header
- Buffer
- Operation
- Field list
- Opt.val.proc
- - servertrans.pInput - Trans header and trans
values Temp-table struct - Dynamic FK validation
- Hooks for custom validation / updates
- Assign defaults
- Returns completed temp-table (option)
Trans.values - Field value list
8AS_lib, main methods
- - GetTempTableJoin( Input List of buffers and
fields, rows-to-batch,startrow and query
criteria). - Checks for appserver / client server and passes
on the - input parameters pluss sessionid to
gettemptablejoin.p - - DoCreate(Input buffer,fields and values).
- - DoUpdate(Input buffer,criteria,fields and
values). - DoDelete(Input buffer,criteria).
- Populate transaction temp-tables.
- - DoCommit(true/false).
- Checks for appserver and passes transaction
temp-tables to servertrans.p. True/False receive
completed buffer back
9UI_lib
- Implements standard events
- and methods. Keeps run-time state for UI objects.
- Objects (currently)
- InitBrowse(..)
- -InitQuery(..)
- -InitFieldMap(..)
- (browse buffer pluss add.
ttObject
ttObjectLink
ttAttribute
ttEvent
info on input/display fields) -InitToolbar(..) -
InitBrowseDropDown(..) Standard
methods DisplayRecord, SaveRecord,
OpenQuery,etc.
10Additional handy stuff
- - ResizeLib.p
- - Dynamic lookup
- - src/adm2/dyntreeview.w (slightly altered)
- - from smartpak/adm2/cal.w (altered)
- - Microsoft OCX tab-folder
- ..
11Coding example
Rectangles are used to represent screen objects
that are created. In this example a toolbar and
a browser. All relevant code for this simple
window is in one procedure, InitWindow. Only the
libraries (AS,UI and Resize are supporting this
.w file no includes).
12Procedure InitWindow
DO WITH FRAME FRAME-NAME hBrowse
DYNAMIC-FUNCTION("initBrowse", / Create a
browse object (New!) /
rectBrowseHANDLE, /
Rectangle to define coordinates for browse /
100,
/ Rows to batch /
"",
/ Browse properties, ie MULTIPLE,NUM-LOCKED
-COLUMNS, etc /
"pccMemberShipTypeMemberShipTypeNameMemberShipTy
peCost",
/ Buffers and
fields ltbuffer1gtltfield1gtltfield2gt..,ltbuffer2gt..
No fields gives all/ "WHERE
iCompanyId " STRING(DYNAMIC-FUNCTION("getCompa
nyId")), "").
/ Misc - for something I
might need in next version.. / hFieldMap
DYNAMIC-FUNCTION("InitFieldMap", / A fieldmap
object holds extra info for display and input
fields (fill-ins)
and their
corresponding buffer columns return handle equals
the buffer handle /
hBrowseQUERY, FRAME
FRAME-NAMEHANDLE, / Frame for the
input/display fields (might not be the same frame
as the browse) /
"MemberShipTypeName,MemberShipTypeCost", /
Update columns in buffer /
"MemberShipTypeName,MemberShipTypeCost", /
Corresponding input fields (fill-in..)/
"","", / Additional
buffer and displ.fields - not updateable/
"").
/ Additional input fields (not in
buffer) / / Assign foreign key values (not
selected by the user) / DYNAMIC-FUNCTION("setA
ttribute",hFieldMap,"bufferextrafields","iCompanyI
d"). DYNAMIC-FUNCTION("setAttribute",hFieldMap,"
bufferextravalues",STRING(DYNAMIC-FUNCTION("getCom
panyId"))). DYNAMIC-FUNCTION("InitToolBar",
rectTBfileHANDLE,
/ Rectangle to define coordinates for
toolbar / "Fil",
/ Corresponding
menu label - no menu if blank /
"newNy,undoAngre,deleteSlett,saveLagre,exce
lEksporter til Excel",
/ Buttons / Menu items
actionlabeltooltipMethodimage,actionlabel..
Any number of
properties accepted (one ok - if predef. action)
/ "maxborder").
/ View and expand border
rectangle to span frame / DYNAMIC-FUNCTION("Li
nkAllObjects", / Link all created
objects. Linktype is type of "to" object,
f.ex link
from browse to combo-box is combo-box link /
THIS-PROCEDURECURRENT-WINDOW,
/ Link only objects created for current window
/ TRUE,
/ Replace any existing links
/ "").
/ Except these objects
list of handles / DYNAMIC-FUNCTION("setCompanyH
eader",THIS-PROCEDURECURRENT-WINDOW). / The
application should supports multiple companies /
DYNAMIC-FUNCTION("setNoResizeY",
THIS-PROCEDURECURRENT-WINDOW, FRAME
FRAME-NAMEHANDLE, "rectTBfile").
DYNAMIC-FUNCTION("setOrgWinSize",
THIS-PROCEDURECURRENT-WINDOW,200,250,0,250).
DYNAMIC-FUNCTION("initTranslation",THIS-PROCEDURE
CURRENT-WINDOW). APPLY "value-changed" TO
hBrowse. / Since the query is opened we want to
display the first record / END.
13Run the window
14Same window again
..this time translated, resized and with
different BG-color Resize and color settings can
be stored pr window pr user
15Another window example
for generic 3-tier database queries
16Run the query
The browse is now created based on user-defined
buffersand fields