This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Member object talks back to parent object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Member object talks back to parent object

Dave Elwood
Ranch Hand

Joined: Dec 27, 2002
Posts: 84
I am in a situation where I have two classes AA and BB,
where "BB bb;" is a member of AA aa.

I wish to send info from the interior of class BB up to class AA.

Note the direction - from AA to BB is easy, since bb is a member of aa, but talking back to aa??

Using events? All literature I find about events deals with Keyboard events, Timer events, Mouse events, all induced by external actions. Nothing about my own custom-made 'burp' events, induced by the code in the BB object.

Is there a method other than using events for a member object to communication with its parent object?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16

your terminology is confusing. 'parent' usually refers to an inheritance relationship:


Member object usually refers to a class being a member variable of another class:



In the second case, it would be very dangerous to expect to be able to do this. How do you know if the member variable is actually in a container class? What if it is in two or more? What if it is one minute, but not the next?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Dave Elwood
Ranch Hand

Joined: Dec 27, 2002
Posts: 84
Yes, my terminology is really for the birds, but whence the worry about membership in a container class??
It doesn't really seem realistic to me.

(And I solved the custom event problem in the meantime)

Anyway this is the scenario.

1. BB bb is a member of AA aa

2. and AA aa is a member of main()

3. In the future AA will be a form with text boxes and a panel and
the class BB will be the code behind the panel (so BB is a member of AA).
I want a change in the panel code to fill in a text box in the AA form when circumstances demand it

This is main()

This is AA

This is BB

These are BurpEvent, BurpListener and MyBurpListener from three files

all the nifty event code is from http://www.exampledepot.com/egs/java.util/custevent.html
>
Dave Elwood
Ranch Hand

Joined: Dec 27, 2002
Posts: 84
found the solution, detailed in

http://www.coderanch.com/t/530049/java/java/Communication-between-EJB-its-container
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
But why did you start a new thread. Closing thread.
 
jQuery in Action, 2nd edition
 
subject: Member object talks back to parent object
 
Similar Threads
Garbage collection
fwd or backward ,don't know which reference??
Casting Doubt
Object serialization
Method Access Question