background image
C H A P T E R 2 1
Routing Interface
Using Routing
21-17
RegisterViewDef
. Nor should you use
DefConst
, or any other method
that directly references the routing format. This is because the entire
InstallScript
function is passed to
EnsureInternal
(for application parts).
Your routing format layouts would be copied into the NewtonScript heap, wasting
precious memory.
Instead, you should use an indirect method to reference your routing format
layouts. One way is to store a reference to your routing format layouts (by using
GetLayout
) in a slot in your application base view (for example,
myRoutingFormat
). Then in the
InstallScript
function, you can reference
that slot through the expression
partFrame.theForm.myRoutingFormat
.
Because the reference to the layout is found at run time through an argument to
InstallScript
, it is not copied into NewtonScript memory by
EnsureInternal
when your application is installed.
For example, first you could store the routing format layout in an application base
view slot:
myRoutingFormat: GetLayout("MyNiceLayout");
Then in the
InstallScript
function, you could use code like this to register the
format:
InstallScript(partFrame)
begin
local myApp := partFrame.theForm;
...
RegisterViewDef(myApp.myRoutingFormat,
kMyMainDataClassSym);
end;
For more information about view definitions and the functions that act on them,
refer to Chapter 5, "Stationery."
Note
If your application uses the NewtApp framework, registering
routing formats is much easier. The NewtApp framework does it
for you. All you have to do is add your formats to the
allViewDefs
frame in the application base view (that is based
on the
newtApplication
proto). For more information, see
"Using the Required NewtApp Install and Remove Scripts"
beginning on page 4-21.
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна