• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Event handling question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Event handling question


  • Subject: Event handling question
  • From: "Richard L. Peskin" <email@hidden>
  • Date: Thu, 3 Apr 2003 17:48:28 -0500

At the end of this message is the Main.java code from Chapter 5
(Derived Properties) of Web Objects 5 (Web Applications) which is the
booklet distributed with WO 5.2. The application consists of two
WOConditionals, one wrapping a simple Form with two user input text
fields and the other wrapping two text fields. My question concerns the
adduser() method which is triggered when the Submit button is pressed.
If the "entryIncomplete" is true (user didn't fill in text fields) the
console message from addUser() is printed. But if "entryIncomplete" is
false (triggering the else branch in entry(incomplete()), the addUser()
message is not printed and the message in that else branch is printed
twice????
--dick peskin
---------
//
// Main.java: Class file for WO Component 'Main'
// Project UserEntry
//
// Created by rpeskin on Mon Mar 31 2003
//

import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;

public class Main extends WOComponent {
     protected String personName;
     protected String favoriteFood;
        public Main(WOContext context) {
         super(context);
          }

         /* print to console */
         public void awake() {
             super.awake();
             System.out.println(this.getClass().getName() + "'s awake
invoked.");
         }

     public String personName()
     {
         return personName;
     }
     public void setPersonName(String newPersonName)
     {
         System.out.println("Setting personName to " + newPersonName);
         personName = newPersonName;
     }

     public String favoriteFood()
     {
         return favoriteFood;
     }
     public void setFavoriteFood(String newFavoriteFood)
     {
         System.out.println("Setting favoriteFood to " +
newFavoriteFood);
         favoriteFood = newFavoriteFood;
     }

     public WOComponent addUser()
     {
         System.out.println("Submit Button clicked" );
         System.out.println();
         return null;
     }

     public boolean entryIncomplete()
     {
       boolean entryIncomplete;
       if (personName == null || favoriteFood == null ||
             personName.equals("") || favoriteFood.equals("") ){
             System.out.println("The entry is incomplete.");
             entryIncomplete = true;
         }
         else {
             System.out.println("The entry is complete.");
             entryIncomplete = false;
         }

         return entryIncomplete;
     }
}
--------------------------


Richard L. Peskin, RLP Consulting, Londonderry, VT
http://www.rlpcon.com
http://www.caip.rutgers.edu/~peskin
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Event handling question
      • From: Art Isbell <email@hidden>
    • Re: Event handling question
      • From: Chuck Hill <email@hidden>
  • Prev by Date: Re: [newbie] General question about WO/Java Client
  • Next by Date: PB after WO 5.2.1
  • Previous by thread: Re: Newbie Sort Question...
  • Next by thread: Re: Event handling question
  • Index(es):
    • Date
    • Thread