entering stuff in JTextField for later use

  2 posts   Feedicon  
Replies: 1 - Last Post: January 12, 2010 18:56
by: Logan Barnett
showing 1 - 2 of 2
 
Posted: January 12, 2010 01:07 by AdamMarker
I started my first Monkeybars project last week and so far it is going well. I've figured out most things by reading the docs & examples. I have a bunch of questions/snags; I'll cover them one at a time.

In spirit, my form looks something like this:
  button (locate vet)
  button (locate pet store)
  JTextField: # of cats ______
  JTextField: # of dogs _____
  button (submit stats)

The user might enter the # of cats and dogs first, then locate vet, then locate pet store. The only order required is to fill in the text fields before pressing the 'submit stats' button.

I'm trying to figure out when and how to move the numbers from the text fields to the model. Each of the 'locate' button controller actions call update_view (since they cause changes to the model). If I 'map' the text fields, then each button press overwrites any user-entered numbers with the defaults I've set in the model.

I don't really have any use for the numbers until the user presses 'submit stats'. Do I need to add a document listener (as I read in another thread) ... then write the numbers from the view to the model in every button action? (Note -- my app has more buttons, more text fields). I tried removing all the 'map' statements and setting the model by hand in the 'submit stats' controller action, but I can't get the syntax right.

It feels like my newness to the platform is missing something. Thanks for Monkeybars, it's helping me a lot.
 
Posted: January 12, 2010 18:56 by Logan Barnett

Adam, This is exactly why we have controller#signal and view.define_signal (:

Signal is for one-off view alterations from the controller to the view. Get your model/transfer in the state it needs to be, then fire a signal. The view's signal handler looks an awful lot like a raw mapping (and it is reusable/interchangeable with a raw mapping).

Let me know how that works for you!

-Logan

Replies: 1 - Last Post: January 12, 2010 18:56
by: Logan Barnett
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120127.ac94057)
 
 
Close
loading
Please Confirm
Close