Announcement Announcement Module
Collapse
No announcement yet.
How can I be notified when a form field value changes? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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...

    Comment


    • #3
      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 .

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Comment


          • #6
            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

            Comment


            • #7
              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

              Comment


              • #8
                Yeah the good old ValueChangeListener. I remember these good old times... .

                Comment

                Working...
                X