Greg Brown <[email protected]> wrote:
The load case is easier, since presumably you already have the detail from the master to load into the detail form. I'd suggest putting your detail pane in an include, and using a custom class (that probably implements Bindable and extends an existing layout container such as Form) as the root element. This class can expose a bean property, such as "contact" via getContact() and setContact() methods. setContact() can call load():

public void setContact(Contact contact) {
    load(contact);
}

Then in your BXML, you can do:

<bxml:include src="contact.bxml" contact="${table.selectedRow}"/>

That's the push in the right direction I needed! Thanks! That's it!

In fact, the custom container class could be general:

public DataForm extends Form {
  public void setData(Object data) {
    load(data);
  }
}

And in the BXML I'd have:

<my:DataForm data="${table.selectedRow}">
  ...
</my:DataForm>

The store case is tougher, since it depends entirely on how you want to persist the data. Do you want to POST it to an HTTP service? Update a database table? Save it to a file? Something else?

The data will be send to a Spring service bean eventually, a method call such as ContactsManager.save(data).

Since there's not really any generic way to handle this, you'll probably need to write logic to handle stores - however, the store() method makes this pretty easy. Your implementation of getContact() could create a new Contact instance and store() the form to it; then you can do whatever you need to with that object.

All my form panels have a "save" button, which will store the form data back to the selected table row value. I see now that this is easy to accomplish with the above design.

Thanks,
Dirk.



Reply via email to