Apple WebObjects 3.5 User Manual
Page 62

Chapter 4
Debugging a WebObjects Application
62
•
The
pageWithName
method creates the page by looking up and instantiating
the component class that has the same name as the argument you provide
to
pageWithName
. For this reason, your subclass of Component shouldn’t be
given a package name. For example, if you create a component named
MyPage.wo
and place its Java file in the package
myClasses.web
,
pageWithName
won’t
find the
MyPage.class
file.
•
Java is a more strictly typed language than is Objective-C or WebScript. If
you’re more familiar with Objective-C, you’ll find that you need to cast the
return types frequently. For example, suppose you define a method named
verify
in the file
Session.java
and you want to invoke that method from a
component’s Java file. To do so, you must cast the return type of the
component’s
session
method as in the following:
// From a component’s Java file.
((Session)session()).verify();
By definition,
session
returns a WebSession object. Because WebSession
does not define a method named
verify
, your code won’t compile unless you
cast the return value of
session
to your WebSession subclass.