Announcement Announcement Module
Collapse
No announcement yet.
Important questions on binding Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Important questions on binding

    Hi,
    I have some questions regarding spring data binding. For three tier database centric application (as ours) it works fine in the cases where you are inserting new record as screen is empty at that time. But in case of update it does not work as i expected. I fetch the domain model from middle tier so the propertychange support concept did not work fine in this case, as the domain model will be constructed on middle tier so gui widgets will not update them. So if i need to update them manually it will be very tedious and also i have to make new object and calls setters which will be difficult and almost the same amount of code will be required as in manual copying case. And also in case of collection it is alos difficult to re-construct new object (first by iterating the collection). So i think there must be some nicer soltuion to this problem. In our home grown little binding framework we achieve this by extending the normal swing widgets and then call update on our FormObject whic traverses our gui widges and set their value by getting the value form domain model.So we get the object from middle tier and set the FormModel to this object ( assigning the reference ) and then call update on it. I know that our approach is not as tiered as yours one because our custom widgets have refence to our domain model ( they all implement IModel interface) and the propety they are bind to and then use simple reflection , but in the meantime it is very easy too ( as we exposed it using GUI builder as binding is based on Java Beans). But yours binding is excellent and defintely more scalable but i cannot find answer to the above mentioned problem otherwise i wish i can move to your excellent framework as we are already using Spring on middle tier and i wish we could also use spring rcp on client side. Please answer my question or enhance the framework in some way so it can be acheival in a nicer way. one soltuin might be an update method on swing form object. And when you cretae a control it remembers it and when u call update it executes binding by using reflection. I am eagerly waiting for reply from Keith and this nice community.

  • #2
    Hi,
    Anybody who can reply...... how to use binding in three tier app .. Please asap

    Comment


    • #3
      Please reply me. :cry:

      Comment


      • #4
        Please reply me i am in dire need of any input. Keith i think it will take less than 5 minutes of your precious time. Thanks (for best ever swing framework )

        Comment


        • #5
          Hi Shoaib,

          I'm not sure if I quite understand your problem.

          In the middle tier (presumably server-side), you need to pass the domain object over to the client-side. You can then set it as the formObject of a suitable FormModel (eg. DefaultFormModel, ValidatingFormModel, etc). Gui controls (textfields, comboboxes, etc) on your form are bound to properties and property paths.

          When you type text/select values/etc on these gui controls, the values are pushed into the underlying object, which is now 'dirty', compared with what is in the database. Typically, you need some kind of commit trigger (ie. a commit or save button). When commit occurs you then need to send your modifed object back to the middle tier, where you would have a service or dao to do an 'update' to the database.

          I'm not sure if this differs from what you are doing. Could you clarify exactly where the problem is occurring?

          regards,
          Scott

          Comment


          • #6
            Hi,
            Finally i got a reply . But i am afraid that you could not undertsand my point. What i mean to say is that i bind an object to a Form fields. I get my domain model retireved from server side so when my DAo set values on my domain model firing the ProperyChangeEvent does not matter as my server side exists on other physical/logical tier then this domain model gets back to the client where i assign its reference to instant level variable on my front end. Now my setters are never called on client side so no Change event is ever fired now i want to poulate my gui fields with the values of my domain model but as no setters are called on client tier how binding execute beacuse as far as i know the setters should be called on client side so that they fire PropertyChangeEvent to whib\ch binding related code is listener and updates the GUI values . Hope you can understand this "Binding in three tier architecure (Client tier, Service tier, Perstsistence layer) and how could i populate my gui fields witth the values in my domain model (which values rae set on different tier".
            Please reply me asap.

            Comment


            • #7
              The 3 tier model you are referring to is fairly common, and quite supported by Spring RCP.

              You construct your form around a FormModel (DefaultFormModel, ValidatingFormModel, or CompundFormModel). This 'holds' your domain object, and mediates the editing of it.

              When you create a form, you create a SwingFormModel that wraps your FormModel. You then bind the GUI controls (textfield, combobox, etc) to the SwingFormModel (there are heaps of methods within this class to create bound controls or bind existing ones). You actually bind the controls to javabean property names (eg. "name", "address", "phone", etc) or paths (eg. "account.orderId", "company.name").

              The underlying binding is actually a ValueModel implementation that uses reflection to read the property for display, then writes back to the underlying property upon edit event triggers (eg. typing, focus change, combo box selection, etc).

              You don't really need to have your domain objects fire PropertyChange events, unless they are likely to change independently of editing (eg. setting 1 property causes another to change), and the GUI controls would need to be notified to display the new value.

              Once you have set up your FormModel, and bound your GUI Form controls to it, you then just retrieve your domain object from the server, and set it as the FormModel's formObject. All of the plumbing behind the scene will handle reading the properties for display, then pushing the editing changes back into the formObject.

              When you are ready to save the changes, just commit the FormModel, then send the modifed domain object back to the server. Back on the server-side, it is up to whatever O/R strategy you employ (eg. Hibernate, JDO, manual JDBC) to take the modified domain object and use it to update the database.

              I hope this got to the point of what you were trying to express, and I hope I wasn't too long winded ;-)

              regards,
              Scott

              Comment

              Working...
              X