application object one transient instance created for each process used as a kind of transient root...

12
Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied variable called app app.myBank app.myBranch Applicati on myBank myBranch Transien t

Upload: duane-anderson

Post on 18-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

Application Object

• One transient instance created for each process• Used as a kind of transient root object to store

often used references• System supplied variable called app

– app.myBank– app.myBranch

Application

myBankmyBranch

Transient

Page 2: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

Process Starts – Initialise app

2702.1

Branch

name Central City

2702.2

Branch

name Down Town

2601.1

Bank

name JADE Bank

Processapp

ApplicationmyBank 2601.1

myBranch2702.1

Transient

User working with Central City branch

myBank 2601.1

myBranch

app

Transient

Background taske.g. Print Server

Process

Processapp

ApplicationmyBank 2601.1

myBranch2702.2

Transient

User working with Down Town branch

app.myBank

app.myBranch

app.myBranch

app.myBank

app.myBank

# 1

# 2

# 3

Application

Page 3: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

Node

Persistent Cache Transient Cache

TransientDatabase

Background Process

Process

Process

process, node, system

Page 4: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

More System Variables

• currentSession• currentSchema• exception• method• rootSchema• self

Page 5: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

Class Constants

• Different from Global Constants and Local Constants• Viewed in Class Browser

Page 6: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

Class Class

• Used to store class information

• Useful properties– instances

• Useful methods– getProperties– firstInstance

Page 7: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

Subschema Visibility

XRaySchemaXRaySchema OncologySchemaOncologySchema

XRayPatientXRayPatient OncologyPatientOncologyPatient

PatientPatient PatientPatient

allPatients XRayPatients

OncologyPatients

allPatients XRayPatients

OncologyPatients

Subschema Copy Class

Root Class

TreatmentCentreSchemaTreatmentCentreSchema

PatientPatient

TreatmentCentreTreatmentCentre

Root Class

Page 8: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

Challenge #22• Paint a CustomerList form

• Code load method of form

• Code table_displayRow method

name mnuCustomerList

caption &List

• Add a menu item to MainMenu

caption Customer List columns 3

fixedColumns 0

name btnEdit

caption Edit

name table

Page 9: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

Challenge #23

Customer class

• Add a setPropertiesOnUpdate method

CustomerDetails form

• Add myCustomer reference

• Code load method – if myCustomer not null, prefill text boxes

• Add an updateCustomer method

• Modify btnOK_click method – if myCustomer not null, call updateCustomer

CustomerList form

• Code btnEdit_click method

To enable a customer from CustomerList form to be edited:

Page 10: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

List Objects in a Table

table_displayRow(table : Table input; theSheet : Integer; obj : Object; theRow : Integer; bcontinue: Boolean io) : String updating;vars cust : Customer;begin cust := obj.Customer; return cust.firstNames & Tab & cust.lastName & Tab & cust.address;end;

table_displayRow(table : Table input; theSheet : Integer; obj : Object; theRow : Integer; bcontinue: Boolean io) : String updating;vars cust : Customer;begin cust := obj.Customer; return cust.firstNames & Tab & cust.lastName & Tab & cust.address;end;

• Display a row of text for each object in collection

table.setCellText (1, // row1, // column'First Names' & Tab & 'Last Name' & Tab & 'Address'); // text

table.setCellText (1, // row1, // column'First Names' & Tab & 'Last Name' & Tab & 'Address'); // text

• Set headings

table.displayCollection (app.myBank.allCustomers, // collectiontrue, // automatically updated?Table.DisplayCollection_Forward, // forwards or backwardsnull); // start object within collection

table.displayCollection (app.myBank.allCustomers, // collectiontrue, // automatically updated?Table.DisplayCollection_Forward, // forwards or backwardsnull); // start object within collection

• Associate a collection with a table

Page 11: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

Select from a Table

cust := table.accessRow(table.row).itemObject.Customer;cust := table.accessRow(table.row).itemObject.Customer;

accessedColumn

itemObject

accessedCell accessedRow accessedSheet

table

• Access the item object• Type cast as a Customer

Page 12: Application Object One transient instance created for each process Used as a kind of transient root object to store often used references System supplied

Conditional Update

setPropertiesOnUpdate(pAddress : String; pFirstNames : String; pLastName : String) updating;

begin self.address := pAddress; self.firstNames := pFirstNames; if self.lastName <> pLastName then self.lastName := pLastName; endif;end;

setPropertiesOnUpdate(pAddress : String; pFirstNames : String; pLastName : String) updating;

begin self.address := pAddress; self.firstNames := pFirstNames; if self.lastName <> pLastName then self.lastName := pLastName; endif;end;

What is the purpose of the if statement?