[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ganymede Dev] Sensitive Invid Field

Date Wed, 30 Apr 2003 19:03:24 -0500
From Jonathan Abbey <jonabbey@arlut.utexas.edu>

On Wed, Apr 30, 2003 at 11:42:50PM +0000, John King wrote:
| >
| >Well, it would have been helpful if you had actually included your
| >finalizeSetValue() method, rather than just the secondary setDName()
| >method.
| >
| 
| there goes:
| 
| 		//set DName field if the Parent field was changed
| 		if(field.getID() == PARENT){
| 			//tell ganymede wizad is active, only parent and 
| 			zone may activate this wizard
| 			DNameWizardEnabled=true;
| 			//initialize wizard
| 			return 
| ((InvidDBField)getField(PARENT)).rescanThisField(setDName((String)getFieldValueLocal(ZONE)));
| 		}
| 
| I've put an over-amount of rescanThisField's in my source, yes I know. 
| Cleaning up is what I reserve for later after I've made the mess.

Sure, I understand you.

| >The problem is almost certainly that you are trying to use
| >
| >	return ((InvidDBField)getField(PARENT)).rescanThisField(null);
| >
| >to get the value of the PARENT field.. I assume that's the field that
| >your finalizeSetValue() method was called upon to trigger setDName()
| >being called?
| >
| 
| Thats completely right

OK.

| >If you look at the method signature for DBEditObject.finalizeSetValue(),
| >you'll see that it is defined as
| >
| >  public ReturnVal finalizeSetValue(DBField field, Object value)
| 
| field is in this case PARENT, value doesn't matter because I want the 
| current value of ZONE, which is either something or null.

The current value of ZONE?  So you're saying you want the code called
by your finalizeSetValue() method to be able to determine the value of
ZONE from before the time that the PARENT field's value was changed?

I'm confused.

| >in this case, value will be the new Invid to be set into that field.
| >If you do a getFieldValue() or something like that on an
| >InvidDBField() between the time that finalizeSetValue() is called and
| >the time that finalizeSetValue() is returned, you'll always see the
| >old value of the Invid field.
| 
| like I thought. So at
| 		try{
| 		    parentDName = 
| ((StringDBField)getFieldInTarget(PARENT,DNAME)).getValueString();
| 		}

getFieldInTarget()?

| the current value isn't finalized yet. And so I read the previous value..

Well, values aren't finalized.. changes to fields are finalized.  So
in this case, since you are still in the middle of finalizeSetValue(),
the change to the PARENT field hasn't been finalized yet, and if you
try to get the value of the PARENT field, you'll see the old value.

If you want to get the new value that has been submitted for placement
into the PARENT field, you'll need to use

   (Invid) value

where value is the Object passed in as the second parameter of
finalizeSetValue().

| >The whole point of finalizeSetValue() and the other finalize methods
| >is that if your finalize methods don't return a successful ReturnVal
| >or null, the change that you are being notified for will not actually
| >be performed.
| >
| >Does this make sense?
| 
| yes it does. But can I finalize this Invid manually? Or is there some other 
| way to retreive the object referenced to in the yet unfinalized Invid?

Again, you don't finalize an Invid, you finalize a change to a
field.. finalizeSetValue() is called to finalize the act of putting a
new value into a scalar field.

If you want to retrieve an object based on the proposed new Invid
value, you can do something like the following:

  public ReturnVal finalizeSetValue(DBField field, Object value)
  {
     if (field.getID() != PARENT)
       {
          return null;
       }

     // we'll use the DBSession viewDBObject() method here rather than
     // the GanymedeSession view_db_object() method, since we're not
     // going to ever provide otherObject to a remote client.. the
     // DBSession viewDBObject() method is more efficient and doesn't
     // require us to unpack and case the DBObject reference from the
     // ReturnVal getObject() method

     DBObject otherObject = this.getSession().viewDBObject((Invid) value);

     // now we can look at the otherObject to see if it is appropriate to
     // link to..

     if (otherObject != null && otherObject.isSet(ABOOLEANFIELDTOTEST))
       {
         return null;
       }
     else
       {
         return Ganymede.createErrorDialog("Error, can't link to that object",
                                           "I can't link to that object, it doesn't" +
                                           "have field ABOOLEANFIELDTOTEST set");
       }
  } 

Something like that, using the proposed new value passed in to
finalizeSetValue().

That's again assuming you're wanting the new value for the PARENT
field.. you seem to be saying that you want to know what the new value
for the ZONE field is when your finalizeSetValue() method is called
for the PARENT field, which doesn't really make sense.. how do you
know the ZONE field was changed before the PARENT field?

Assuming that the ZONE field already has been changed, then you can
just get the value for the ZONE field like you would anything else,
assuming you have a reference to the editable DBEditObject that
contains that field.  If you have a read-only DBObject reference, it
won't show any changes made to that field, ever.

-- 
-------------------------------------------------------------------------------
Jonathan Abbey 				              jonabbey@arlut.utexas.edu
Applied Research Laboratories                 The University of Texas at Austin
GPG Key: 71767586 at keyserver pgp.mit.edu, http://www.ganymeta.org/workkey.gpg

Attachment: pgp00009.pgp
Description: PGP signature


  • Re: [Ganymede Dev] Sensitive Invid Field
    • From: Jonathan Abbey <jonabbey@arlut.utexas.edu>