Monday, September 8, 2008

Editing shared objects (like Addresses) in XAF as non shared

If you are using the BaseImpl.Address object you'll note how, by default, XAF shows a combobox to select an address making them shared and reusable among Persons.

Usually I don't want to reuse addresses for different Persons or parties.  I prefer the MainDemo style where the addresses are not shared and where popup dialog is opened to edit an address using a button with the three dots.

The trick to change this behaviour is to modify the "PropertyEditorType" for the Address1 and Address2 properties in the Party object and use theses values:

In the Module.Win project:
DevExpress.ExpressApp.Win.Editors.ObjectPropertyEditor

In the Module.Web project:
DevExpress.ExpressApp.Web.Editors.ASPx.ASPxObjectPropertyEditor

This is how it looks like before the change (click to enlarge):

And this is after the change:


To change it, open the model in the web or win project go to the party object (or the parent object containing the addresses) and change the PropertyEditorType for the Address field. The model should look like this:



Do you know a better way to do it?

2 comments:

Robert Thomas said...

Dani,
Very nice find. I was considering taking the whole shared address object out of the core persistent classes because I don't like the old behavior. Thanks!

Bob

Dani Mora said...

Thank you Robert! Nice to know you found it useful.