Apple WebObjects 3.5 Bedienungsanleitung Seite 49

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 218
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 48
Initialization and Deallocation Methods
49
Component Initialization
A component object’s init method is invoked when the component object is
created. Just how often a particular component object is created depends on
whether the application object is caching pages. For more information, see
“WebObjects Viewed Through Its Classes” (page 63). If page caching is
turned on (as it is by default), the application object generally creates the
component object once and then restores that object from the cache every
time it is involved in a user request. If page caching is turned off, the
component object is freed at the end of the request-response loop.
Note: The pageWithName: method shown in the section “Action Methods”
(page 43) always creates a new component object, even if page caching is
turned on.
A component object’s
init method usually initializes component variables.
For example, in the EmployeeBook example, the
Department.wos script uses
init to initialize the departments component variable:
// WebScript EmployeeBook Department.wos
id departments;
- init {
id departmentsPath;
[super init];
departmentsPath = [[self application]
pathForResourceNamed:@"Departments" ofType:@"array"];
departments = [NSArray arrayWithContentsOfFile:departmentsPath];
return self;
}
The component awake method is invoked immediately after the init method
and each time the component object is restored from the page cache. Just
as in
init, you can implement an awake method that initializes component
variables. For example, in the DodgeDemo application, the
Car.wos script
uses
awake to initialize the shoppingCart component variable:
// WebScript DodgeDemo Car.wos
- awake {
shoppingCart = [[self session] shoppingCart];
}
In general, you use init to initialize component instance variables instead of
awake. The reason is that init is invoked only at component initialization time,
whereas
awake is potentially invoked much more than that. If, however, you
want to minimize the amount of state stored between cycles of the request-
response loop, you might choose to initialize component instance variables
in
awake and then deallocate them in sleep (by setting them to nil in WebScript
Seitenansicht 48
1 2 ... 44 45 46 47 48 49 50 51 52 53 54 ... 217 218

Kommentare zu diesen Handbüchern

Keine Kommentare

IBM 612 manuales

Manuales del propietario y guías del usuario para Accesorios De Computador IBM 612.
Ofrecemos 1 manuales en pdf IBM 612 para descargar gratis por tipos de documentos: Manual de usuario






Más productos y manuales para Accesorios De Computador IBM

Modelos Tipo de documento
Data Server DB2 Manual de usuario   IBM Data Server DB2 User Manual, 298 paginas
DB2 Everyplace 7.2.1 Manual de usuario   IBM DB2 Everyplace 7.2.1 User Manual, 18 paginas
6633 - 4LE Manual de usuario   IBM 6633 - 4LE User Manual, 19 paginas
8271 Manual de usuario   IBM 8271 User Manual, 6 paginas
Volition Dual Speed Mini-Hub VOL-2008 Manual de usuario   IBM Volition Dual Speed Mini-Hub VOL-2008 User Manual, 3 paginas
02L1333 Manual de usuario   IBM 02L1333 User Manual, 6 paginas
ZG09-0629 Manual de usuario   IBM ZG09-0629 User Manual, 24 paginas
19K4260 Manual de usuario   IBM 19K4260 User Manual, 105 paginas
THINKPAD S05L-1270-01 Manual de usuario   IBM THINKPAD S05L-1270-01 User Manual, 716 paginas
iSeries 270 and 820 SENG-3002-01 Manual de usuario   IBM iSeries 270 and 820 SENG-3002-01 User Manual, 30 paginas
524 Manual de usuario   IBM 524 User Manual, 2 paginas
8260 Manual de usuario   IBM 8260 User Manual, 25 paginas
250000 Manual de usuario   IBM 250000 User Manual, 19 paginas
X3950 M2 Manual de usuario   IBM X3950 M2 User Manual, 19 paginas