Announcement Announcement Module
No announcement yet.
Forms and nested properties Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Forms and nested properties

    I have been experimenting with Spring RCP for a new project and have been impressed. Although things have been a little hard to figure out at first, "problems" have usually been solved by studying the code a little more and saying "aha!. Great work guys!

    However, there's one problem that I just cannot figure out how to solve and that's how to link several Forms to one FormModel In this case, I'd like to be able to edit the contact and customer properties on an order instance. Both properties are of the same class (Actor) have identical Forms to edit them. I've implemented this with an order View which creates a compound FormModel and hooks up three Forms (one for the Order details and two for the two nested Actor instances). To bind the customer and contact forms to their Actor instances, I thought I could do this by passing the result of a createChild:
    CompoundFormModel orderFormModel = new CompoundFormModel(order);        
    SwingFormModel customerFormModel = new SwingFormModel(orderFormModel.createChild("customerForm", "customer"));
    SwingFormModel contactFormModel = new SwingFormModel(orderFormModel.createChild("contactForm", "contact"));
    This however results in behaviour where each of the child models traverse the full order for finding properties. E.g when binding the "id"-property which Actor and Order instances have, the order's id will be bound for the child forms and when binding the "name" property, the value will be retrieved from the first actor instance for both child forms.

    What is the correct way to do this?