Michael McGrady wrote:
I don't know what a "copy of a reference" (which should just be a number indicating where to find the object) would be, Erik.
I think you already know what I mean, but I'll post this for the greater good of the archive. :)
. . .
Object o = new Object(); modifyInstance(o); // "o" here is called an "actual parameter"
. . .
public void modifyInstance(Object o) { // "o" here is called a "formal parameter"
// my reference, or parameter, "o", is not the same
// reference as "o" in lines 1 and 2 above,
// though it does refer to the same object . . .
// (if it *was* the same reference, Java would
// be using call-by-reference, and I would be able
// to change the caller's reference "o" to
// refer to another object from here!);
// thus, I say, I must be working with
// a copy of that reference!
// perhaps I need a better word than "copy",
// as you suggest (a book I have uses "alias" --
// probably better),
// but you see what I mean . . .
}
I do know what a copy of an object would be. I am not thinking of changing the reference to a different object but giving the reference itself a different object. E.g.Yes. I thought the point was to change the reference to the ActionMapping that is passed to the Action.execute method. There you have a different situation because of the method's return value. Sorry if I misunderstood. I jumped in late.
ActionForm method(ActionForm actionForm) { // set the same reference. ActionForm af = actionForm; // now reset the form with that reference af = DynamicActionFormFactory.getBlankForm(name,type,fields); return af; }
This make sense to you?
Michael McGrady
Erik
At 02:15 PM 8/6/2004, you wrote:
Java passes a *copy* of the reference (thus, Java always passes parameters using call-by-value), not the actual reference. So, changing the passed-in reference from within the method to refer to a different object will not cause a change in the reference of the guy who called the method -- his reference will still refer to the old (unchanged) object. However, since the passed-in reference refers to the same object as the caller's reference, you can modify the object itself via your reference and the caller will see the changes. So you could invoke setParameter, etc., on the ActionMapping provided . . .
It's a matter of syntax really, you can still accomplish what you are talking about.
Erik
Michael McGrady wrote:
At 01:44 PM 8/6/2004, you wrote:
If I understand you correctly...
Same issue.... it's passed into the execute method, and therefore you can't change it, only it's internals, so you would have to do the same thing there.
I'm talking specifically in the execute method, which is where I think you're trying to create the form.
I'm perhaps confused, then, Jim. My understanding is that Java never passes more than the reference, so why could we not change the mapping and the form in execute? Why cannot we, in other words, take the reference and reinitialize it to a different ActionForm, ActionMapping, or whatever?
Michael McGrady
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]