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

Re: [Ganymede Help] setting a field value...

Date Thu, 16 May 2002 14:27:14 -0500
From Jonathan Abbey <jonabbey@arlut.utexas.edu>

On Thu, May 16, 2002 at 02:59:45PM -0400, Gaurav Bhargava wrote:
> Hey JOn,
> I used the methods , 
> 
> if (field.getID() == OWNER)
>     { 
>       System.out.println("I am here "); 
>       strField = (StringDBField) getField(ROOMNUMBER);
>       retVal = strField.setValueLocal("Value set");
> 
>       if (retVal != null && !retVal.didSucceed())
>         {
>           System.out.println("Error setting ROOMNUMBER field!");
>           System.out.println(retVal.getDialogText());
>         }
> 
>       System.out.println("I am now here");
> 
>       return null; // approve the operation even if setting the 
> ROOMNUMBER failed
>     }
> 
>   return null; // if we weren't changing the OWNER field, always approve
> }
> 
> it doesnt give any error message on the console rather it just prints 
> the two print statements......i dont know whats going on here........is 

I'm not sure either, Gaurav, it will depend on what else you have
going on in your custom code.

Remember, when you call setValueLocal() on your ROOMNUMBER field, that
operation goes through all of the normal validation steps that any
other field change does.

You could add this code to your finalizeSetValue() method see more
about what is or is not happening:

  if (field.getID() == ROOMNUMBER)
    {
      System.out.println("Finalizing ROOMNUMBER set attempt:");
      System.out.println("Old value: " + this.getFieldValueLocal(ROOMNUMBER));
      System.out.println("New value: " + value)

      return null;  // approve setting the new value into the ROOMNUMBER field
    }

This way you'll be able to tell if some other place in your code is
setting the ROOMNUMBER field back to null or some such.

One thing that I could imagine might be causing problems is if you are
running into an Exception someplace along the way.  Have you been
checking your debug log to see if you're hitting a
NullPointerException or the like?

> there anything i am missing here. DO you need any other specification 
> for this .......please do let me know.I have a field called AID which 
> has name space constraint , if i try to set a value in that field which 
> allready existst then it gives me an  error on console but when i try 
> it with a fresh value it doesnt set 
> anything................................Pls help.

Hm, that's a good sign, it is doing what it should do at least part of
the way, but something along the way may be undoing your change.

Say, maybe the problem is that the change in the ROOMNUMBER field is
simply not immediately visible?  The way Ganymede works, setting a
field through server-side code isn't enough for the client to
immediately know that you did it.  You'd have to view the object
again, or commit the transaction and edit it again.  Have you tried
committing your tranaction after making your change to the OWNER
field, or have you just been giving up because you don't see the
change take place?

If you want a finalize method to make a change to an field and then
have the client immediately refresh that field on screen, you need to
return a value which tells the client to do that, using the
addRescanField() method in the ReturnVal class, like this:

if (field.getID() == OWNER)
    { 
      System.out.println("I am here "); 
      strField = (StringDBField) getField(ROOMNUMBER);
      retVal = strField.setValueLocal("Value set");

      if (retVal != null && !retVal.didSucceed())
        {
          System.out.println("Error setting ROOMNUMBER field!");
          System.out.println(retVal.getDialogText());
        }
      else
        {
          retVal = new retVal(true, true);  // indicate success
          retVal.addRescanField(this.getInvid(), ROOMNUMBER);
        }

      System.out.println("I am now here");

      // pass back a successful ReturnVal with a rescanField instruction
      // if we succeeded in setting ROOMNUMBER, else return back the
      // error condition that prevented the setValueLocal() call from
      // completing

      return retVal; 
    }

  return null; // if we weren't changing the OWNER field, always approve
}

I just now looked at my DBEditObject subclassing guide, and I see that
I only mention this rescan stuff in passing, and don't give a specific
example of it in use.  I don't blame you for being confused by this
stuff.

If it's any consolation, all of this stuff that we talk about is going
into a file of notes that we'll be drawing from in improving the
Ganymede documentation. ;-/

> Thanks fot your help.
> Gaurav Bhargava
> (484)-919-0105(cell)
> (610)-687-1941(Res.)
> http://www.homepage.villanova.edu/gaurav.bhargava

-- 
-------------------------------------------------------------------------------
Jonathan Abbey 				              jonabbey@arlut.utexas.edu
Applied Research Laboratories                 The University of Texas at Austin
Ganymede, a GPL'ed metadirectory for UNIX     http://www.arlut.utexas.edu/gash2


  • Re: [Ganymede Help] setting a field value...
    • From: Jonathan Abbey <jonabbey@arlut.utexas.edu>