Ticket S19008
Visible to All Users

Show complex dialogs in XAF ASP.NET applications (similar to the MessageBox in Windows Forms)

created 17 years ago
Comments (2)
Dennis Garavsky (DevExpress) 14 years ago

    Answers approved by DevExpress Support

    created 8 years ago (modified 8 years ago)

    XAF 17.1+
    Text notification display (e.g. confirmation messages, warnings, errors) has been simplified for desktop and Web XAF applications with the help of the platform-agnostic DevExpress.ExpressApp > ShowViewStrategyBase > ShowMessage  method. You can quickly learn more about it from this blog as a preview of this functionality was already available in XAF v16.2.5+.
    With v17.1, this functionality was greatly extended based on customer feedback and you can research it further in the FeatureCenter and SimpleProjectManager demos:
    [C#]

    We also look forward to hearing from you once you have had an opportunity to try this extended ShowMessage functionality in v17.1 (please submit separate tickets using the https://www.devexpress.com/Support/Center/Question/Create service for that purpose).
    .

      Comments (3)

        Hi Dennis,

        Many thanks to you and the DevExpress XAF team for provviding this long awaited functionality. Will try it soon. And a bit curious to know whether there is an option which when enabled shows the confirmation messages automatically ( like onSaved or OnDeleted, etc…)

        My project has over 100 business objects and was always looking to apply save conformation to inform the user about the success of save acrion.

        Dennis Garavsky (DevExpress) 8 years ago

          @Mohammed: Even though there is no option exactly for this scenario, it is quite straightforward to implement it using a custom ViewController by subscribing to the IObjectSpace events.
          We will be happy to receive more feedback from you once you test this feature live. I would kindly ask you to submit separate tickets using the https://www.devexpress.com/Support/Center/Question/Create service for each issue or suggestion you might have not to distract other XAF users tracking this thread. Thanks for your understanding.

            This is perfect Dennis! I missed it somehow. A true improvement of my XAF web applications. Thanks!

            created 8 years ago (modified 8 years ago)

            We have implemented the functionality described in this ticket. It will be included in our next update(s).

            Please check back and leave a comment to this response to let us know whether or not this solution addresses your concerns.

            Additional information:

            With version 16.2, the use of custom dialogs has been simplified for both WinForms and ASP.NET applications. The ShowViewStrategyBase.ShowViewInPopupWindow method displays the specified View in a popup dialog with OK and Cancel buttons.

            C#
            Application.ShowViewStrategy.ShowViewInPopupWindow(Application.CreateListView(typeof(Contact), true));

            You can also pass the okDelegate and cancelDelegate  parameters to this method, to specify the code to be executed when the OK and Cancel  buttons are clicked. Button captions can be customized using the okButtonCaption and cancelButtonCaption parameters.

            The ShowViewInPopupWindow method provides a platform-agnostic way to display popup dialogs from your code. However, there are certain specifics in ASP.NET applications:
            - The ShowViewInPopupWindow method can be used on XafCallbackManager callbacks initiated by the RaiseXafCallback script. It cannot be used on callbacks of controls (e.g., grid sorting).
            - It is impossible to pause the current request to wait for the user input.
            - Main window is not refreshed when the Cancel button is clicked.

              Show previous comments (5)
              Dennis Garavsky (DevExpress) 8 years ago

                @Mohammed:
                Yes, Mario is absolutely correct (thanks for your help!). This concept is not directly related to XAF, and you can learn more about it from public community resources:
                https://en.wikipedia.org/wiki/Separation_of_concerns
                https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
                If you experience any further difficulties, do not hesitate to submit separate questions using the https://www.devexpress.com/Support/Center/Question/Create service. Thanks.

                  @Dennis @Mario
                  What Mohammed basically wants to achieve is to send a message from a BO to a view.
                  That's not wrong per se, that's why the Messenger class exists in MVVM and the like.
                  XAF's MVC just doesn't have a Messenger, AFAIR.
                  Cheers.

                  MB MB
                  Mario Blatarić 8 years ago

                    @Robert
                    XAF is a bit different since it is not just MVC it is also application generator which means "view" part is dynamic and you do not deal with it as in traditional MVC system.
                    This is where XAF controllers come into play - they both controllers in traditional sense (where you define business logic), but is also a "link" between model and view since controllers are only way to access view in runtime.

                    Additionally, XAF already has many integrated modules which help you solve standard issues. For instance, you use Appearance and Validation module to decorate business classes and members and achieve quite many results like custom coloring, checking values in many different ways, providing validation message to UI and so on.

                    So in XAF, controller class is a bit more than in traditional MVC and it is the place where you register events which respond to certain business object events and delegate information towards view. There are plenty events to do so it all depends on specific requirements.
                    But business object should handle ONLY itself, be that setter method that set another members based on value, or doing some in-instance logic in OnSaving method or initializing in AfterConsutruction. Even appearance and validation module are designed to follow this - you always validate one particular instance of a class.

                    For instance, if you want to check some things before you save object, you might want to do that in object's OnSaving method - but that would be wrong. Instead, you create controller for that class and subscribe to ObjectSpace.Committing/Commited event or ObjectSpace.ObjectChanged event where you can respond to any object change or do any additonal checks before saving data - and there you can then show dialogs, exceptions or whatever else you need to do.
                    That way business object remained clean, dealing only with itself and you know that any additional logic is inside controller.
                    True, there is a learning curve. When I look at my first XAF project - and get strong desire to rewrite it from scratch :-)
                    But once you get a grasp of it, it feels very natural, powerful and well designed.

                    Regards,
                    Mario

                    created 13 years ago (modified 6 years ago)

                    I want to close this ticket with a solution that was successfully used by many of our users through these years.
                    You can write a platform-agnostic code for displaying a confirmation dialog by usingPopupWindowShowAction that will display a DetailView of a non-persistent object or even a DashboardView with a text, image, etc. Take special note that you can also use other approaches to display this dialog (e.g., without using Actions): Ways to Show a View.
                    It is easy to implement and, taking into account ASPxPopupControl integration in 12.1, this looks like a good solution that fully meets the original requirement. Attached is a small sample project + a screenshow showing how it looks in Win and Web UI.
                    To use this solution in your project, copy the Solution28.Module/Model.DesignedDiffs.xafml and Solution28.Module/Controllers files into your platform-agnostic module.
                    Finally, in case you want to display a simple error message for both platforms, you can throw a UserFriendlyException. If you want to display a message box from your persistent object scope, you can use solutions described in the following threads:
                    Web - implement windows-like MessageBox
                    Generic Message Box

                      Show previous comments (9)

                        Hi Dennis, The projects that you attached(dxSampleS19008_16.1.6(12.2_Compatible)) has working popup. When I tried implementing the same in my project it still comes out as a modal popup. Why is that so?

                          Here's your screenshot

                          Dennis Garavsky (DevExpress) 8 years ago

                            @Duane: I've created a separate ticket on your behalf (T541695: New Web UI - How to show a popup confirmation window in the center of the screen). It has been placed in our processing queue and will be answered shortly.

                            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.