Results 1 to 8 of 8

Thread: How can I be notified when a form field value changes?

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    23

    Default How can I be notified when a form field value changes?

    Okay, I'm sure I'm being a total idiot here, which is fine since that would mean the answer is out there! I'm using Spring RCP to build a form dynamically based on a set of named properties from an external XML file. That all works fine. Now I want to perform an action anytime a value in one of the form fields has changed. I've tried to call:
    Code:
    getFormModel().addPropertyChangeListener(propertyName, listener);
    and:
    Code:
    getFormModel().addFormPropertyChangeListener(propertyName, listener);
    after I've associated the named property with a property editor either via:
    Code:
    getFormModel().registerCustomEditor(propertyName, propertyEditor);
    or:
    Code:
    getDefaultComponent(propertyName);
    The former doesn't seem to do anything at all and the latter bombs with an IllegalArgumentException saying the named property has not been added to the form or any of its parents.

    Again, all I really want to do is get called back when the value referenced by propertyName is updated by Spring RCP because of a change in the form fields.

    Help!

    Thanks in advance,
    Scott

  2. #2
    Join Date
    Feb 2005
    Posts
    23

    Default

    Nothing, eh? So is this not possible with Spring RCP yet? I would've thought this would be a common idiom for folks using Spring RCP to build their UIs. I know that Spring does quite a bit of the things for you that we do through custom event handling like validation, etc., but there's always a need to know if a value has changed and to register a listener for that change...

  3. #3
    Join Date
    Aug 2004
    Location
    Germany, Magdeburg
    Posts
    279

    Default

    Hi,

    That has nothing to do with Spring RPC I guess. Maybe a lack of documentation.

    I am not used to it, too, but here is what I would do.

    Create a simple scenario. One form entry, the simpliest model you can think of and then try to listen to input changes. Don't this by trying. Just check the form element implementation. Check the code. This is open source so review the code.

    Once you identified the method getting called (mostly I guess this would be the Swing component used for visualisation) set a breakpoint and see the next step. What events are sending, and why. Select the event you think would apply to your situation best and here you go. You learned how everything works and you solve your problem.

    Try it yourself for lets say 2 hours if you are out of luck, send me your entire small sample project and I will investigate it for you just to prove my claiming right .

  4. #4
    Join Date
    Feb 2005
    Posts
    23

    Default

    Yeah, that was going to be my next step, and I've already pored over the source a bit, but not in depth. I thought I'd post up here in case this was a brain dead operation, but apparently it's not.

    Thanks,
    Scott

  5. #5
    Join Date
    Aug 2004
    Location
    Germany, Magdeburg
    Posts
    279

    Default

    If I remember correctly each Swing text field has the abbility for key evaluation and validation so there should be a way for sure :-).

    Wait a sec. You remember me. Check out JGoodies. They provide evaluation marks for formular fields. I dont know if this evaluation is done on the fly but I guess so. So check this code!

    Here is the URL:

    http://jgoodies.com/products/screenshots.html Check the Overlay Icons screenshot. I guess you may find a demo demonstrating this field checking.

  6. #6
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    Scott,

    can you please post some code. This is certinly a "brain dead operation" and if it's not working you've hit a bug.

    Ollie

  7. #7
    Join Date
    Feb 2005
    Posts
    23

    Default

    Quote Originally Posted by oliverhutchison
    Scott,

    can you please post some code. This is certinly a "brain dead operation" and if it's not working you've hit a bug.

    Ollie
    I did get it working. Meant to post back up. I changed to using ValueChangeListeners instead of PropertyChangeListeners. But that wasn't the only issue. I also had a timing issue where I was trying to initialize some properties that use default components before getDefaultComponent() had been called (thouigh I said earlier that it had been).

    Thanks for the replies!
    Scott

  8. #8
    Join Date
    Aug 2004
    Location
    Germany, Magdeburg
    Posts
    279

    Default

    Yeah the good old ValueChangeListener. I remember these good old times... .

Similar Threads

  1. Replies: 3
    Last Post: Jun 8th, 2010, 03:27 AM
  2. Replies: 4
    Last Post: Jun 13th, 2006, 05:21 PM
  3. Not updating a form field on setFormObject()?
    By SCWells72 in forum Swing
    Replies: 13
    Last Post: Aug 28th, 2005, 12:43 PM
  4. Replies: 2
    Last Post: Oct 27th, 2004, 10:44 AM
  5. How to mark a form field as required???
    By Christian in forum Web
    Replies: 4
    Last Post: Sep 21st, 2004, 02:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •