Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to reference an Object in main from a called method

 
Laura Wells
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some code that will pass in a couple of parameters and call a method. This method will get parent/child objects.

The web page is a list of reports and I want to return the report object for each one when the report title ends with "Revenue per Day".

How do I reference the CurrentObject that is returned from the called method (inside of the main loop)?

[ September 26, 2005: Message edited by: Michael Ernest ]
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So if you use an object reference reportLink to talk to a GuiTestObject in memory, you can make whatever calls on it you like that are supported by the GuiTestObject's interface. It would just be reportLink.whicheverMethod(whicheverargs) as described (hopefully) by the accompanying documentation.
 
Laura Wells
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the feedback.
I have a follow up question ... why would it be "reportLink"
rather than "CurrentObject" which is the object I'm returning?
reportLink.whicheverMethod(whicheverargs)"

Shouldn't I need to reference it by the object name I'm returning?

Laura
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not at all. The name 'CurrentObject' is local to the called method; it's declared and used within the method. Therefore once the method completes its run, the CurrentObject reference will go away.

In the body of your main method, what your code calls 'reportLink' is another reference name that points to what CurrentObject pointed to. If for clarity's sake you wanted to change the name 'reportLink' to 'CurrentObject' you could do that.
 
Laura Wells
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getChildObject is the method name....correct?
 
Laura Wells
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info on the CurrentObject reference. That makes sense.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic