Apple WebObjects 3.5 Instrukcja Użytkownika Strona 46

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 120
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 45
Chapter 2 Enhancing Your Application
46
The table should now look like this:
3. Save the Main component.
Creating the Guest Object
Earlier in this chapter, you created a Java class of type Guest and wrote a
constructor for it. You also added a variable of that class,
currentGuest, to the Main
component. However, adding a variable in this way doesn’t actually create a new
Guest object; you need to create one explicitly at some point in your code.
You’ll create the Guest object in the constructor method for your component.
This method is called when the component is first created; that is, the first time
the user accesses the component.
Note: In WebScript or Objective-C, you use a method called init for this purpose.
1. Choose View Source File from the pull-down menu at the bottom of the
window.
Project Builder becomes active and displays the code for
Main.java. Notice
the following declaration that was added to your code when you added the
currentGuest variable:
protected Guest currentGuest;
2. Delete the declarations of guestName, email and comments, since you aren’t using
them anymore.
3. Add the constructor method inside the Main class definition:
Main() {
super();
currentGuest = new Guest();
}
The first statement calls the constructor of Main’s superclass (which is
next.wo.Component). The second statement allocates a new empty Guest
object and calls Guest’s constructor to initialize its instance variables.
Przeglądanie stron 45
1 2 ... 41 42 43 44 45 46 47 48 49 50 51 ... 119 120

Komentarze do niniejszej Instrukcji

Brak uwag

Bulova Nie podręczniki użytkownika

Zaczynanie od A

Kliknij na poniższy alfabet, aby przejść do pełnej listy modeli zaczynających się od tej litery

Modele Rodzaj dokumentu
ALL-PRO EI700AT
Instrukcja Użytkownika       Bulova ALL-PRO EI700AT User's Manual, 6 strony
ALL-PRO ET500R
Instrukcja Użytkownika        Bulova ALL-PRO ET500R User's Manual, 4 strony