Based on the number of occurrences in the Support Center I feel that not many of you know that with XAF it is possible to invoke a dialog window from a business object context and do so without using any controllers or methods of the XafApplication class (these solutions are based on configuring the ShowViewParameters object or a ViewShortcut).
The solution I would like to tell you is to create a method marked with the ActionAttribute and accept a non-persistent object as a parameter. XAF will recognize such a method and generate a PopupWindowShowAction for it in the UI.
When you execute this command, XAF will show a DetailView of a specified non-persistent object. Since XAF generates Views based on your data model, your can code your non-persistent object to contain required input fields. Of course, you achieve a more complex UI by providing custom editors, customizing layout, etc.
Refer to the "Create An Action that Displays the Pop-up Dialog" section of the How to: Create an Action Using the Action Attribute help article for more details and a complete example.
I think that this platform-agnostic solution is best for simple scenarios where:
- you need to gather input from end-users and execute a custom business logic based on the gathered data;
- your custom logic is not complex and deals with the current and related persistent objects only.
You may also be interested in a more complex and flexible example on the subject:
However, I believe that for such complex scenarios it is best to use a Controllers, which is not only more natural (normally, it is best practice for business objects not to be tied to a UI or deal with UI-related entities), but is aslo more flexible as you have full control over the UI and not limited to the business object scope.
I hope this helps.