How To: Have your Dialog form fields write to arbitrary nodes
Recently I had a customer ask me to help them create a user profile page made up of multiple components with their individual dialogs e.g. address component, name component etc. However; they needed all the content to be written to a single "profile" node in the repository. The solution is fairly simple.
Configure your widget to write to a node (other than the current node)
In this case the "phone" field in the contact component dialog needed to write to the profile node. To do this,
1. Create your "phone" widget node as usual.
2. Set the value for the "name" property to "../profile/phone".
Configure your widget to load data from a node (other than the current node)
1. Create a node of type nt:unstructured under your widget node and call it "listeners".
2. Add a property called "loadcontent" to your listener node and set it's value to a function that retrieves content from another node and sets it to the field. e.g.
function(){this.setValue(CQ.Util.eval(CQ.HTTP.get(CQ.shared.HTTP.getPath()+'/_jcr_content/profile/phone.infinity.json')).phone);}
That's it! The field in your dialog will now read and write it's content from a "profile" node that is a sibling of the current node. Of course you can also use absolute paths if you need every instance of your component to read or write to a specific node in the repository.