Current filter:
                                You should refresh the page.
                                  • -----------------------------------------------
                                    The Mobile UI is in maintenance mode. However, our installation still includes the Mobile UI. We continue to provide support and fix critical bugs, but we do not create new features. Once the new SPA UI is mature, it should cover all the Mobile UI scenarios and also provide new functionality. Refer to the New XAF HTML5/JavaScript SPA UI for Web & Mobile (CTP) KB article for more information on the SPA UI.

                                    This article describes how to extend an XAF Mobile application to provide the capability to change the application's Data Service dynamically after logon.

                                    You need to supply the same application to different customers (companies). Company data should be stored separately in different databases. The database (or, to be more precise, the Data Service connected to it) should be selected in one of the following ways:
                                    1.  The user enters his or her credentials, and the application's Data Service is changed dynamically based on the logged in user.
                                    2. The user specifies his or her Data Service manually in the logon screen, for instance: http://localhost:2064/DataService2.svc.

                                    Your feedback is needed!
                                    This is not an official feature of our Mobile UI (CTP) and our API may change in future release cycles. We are publishing this article prior to the 17.2 release to collect early user feedback and improve overall functionality. We would appreciate your thoughts on this feature once you've had the opportunity to review it. Please report any issues, missing capabilities or suggestions in separate tickets in our Support Center. Thanks for your help in advance!

                                    Install any v17.1.5+ version. The implementation steps below are given for an XAF mobile application with the security system enabled (AuthenticationStandard).

                                    Implementation details
                                    By default, XAF Mobile applications retrieve data from the WCF Data Service published on the same server that is used to build the application for mobile devices (usually, the Data Service URL is something like http://<yourhost>/DataService.svc). This server can be changed dynamically through the ServiceUrl parameter available on both the client and server sides. Note that, although the Mobile application will use the specified Data Service after logon, it is still required to maintain the common Data Service instance in the default deployment. It will be used by the mobile application at startup.
                                    Below, we will describe two approaches of changing the application's Data Service that were mentioned in the Scenario section earlier.

                                    1. Assigning the Data Service URL automatically based on the currently logged user
                                    Mobile applications store global settings in the GlobalModelManager object available via the MobileApplication.GlobalModelManager property. To change a certain option, use the GlobalModelManager.UpdatePropertyValue method. This way, you can programmatically assign a custom URL to the ServiceUrl option.

                                    In the YourSolutionName.Mobile/MobileApplication.xx file, override the MobileApplication's OnLoggedOn method  (or handle the XafApplication.LoggedOn event from other places) to be able to get the current user as follows:

                                    using DevExpress.ExpressApp; using DevExpress.ExpressApp.Mobile; //... namespace YourSolutionName.Mobile { public partial class YourSolutionNameMobileApplication : MobileApplication { protected override void OnLoggedOn(LogonEventArgs args) { base.OnLoggedOn(args); string url = GetUserUrl(this.Security.User); this.GlobalModelManager.UpdatePropertyValue("ServiceUrl", url); } public string GetUserUrl(object user) { // return the service url for the received user } //... } }
                                    Imports DevExpress.ExpressApp Imports DevExpress.ExpressApp.Mobile '... Namespace YourSolutionName.Mobile Partial Public Class YourSolutionNameMobileApplication Inherits MobileApplication Protected Overrides Sub OnLoggedOn(ByVal args As LogonEventArgs) MyBase.OnLoggedOn(args) Dim url As String = GetUserUrl(Me.Security.User) Me.GlobalModelManager.UpdatePropertyValue("ServiceUrl", url) End Sub Public Function GetUserUrl(ByVal user As Object) As String ' return the service url for the received user End Function '... End Class End Namespace

                                    2. Allowing end-users to manually select the Data Service URL in the logon screen
                                    This functionality can be implemented using a custom Logon Parameters class. You can find a complete sample project demonstrating this approach in the attachment. In the attached project, additional data services are added to the Mobile project. So, it will be sufficient to start this project from the Visual Studio to launch these services and check the example in action.

                                    2.1.  In the YourSolutionName.Module project, implement Custom Logon Parameters with an additional property (e.g., ServiceUrl). This will add an editor for specifying the Data Service URL to the logon screen. Note that you can inherit your logon parameters class from the existing one (e.g., AuthenticationStandardLogonParameters) instead of implementing its functionality from scratch:

                                    using DevExpress.ExpressApp.Security; namespace YourSolutionName.Module.BusinessObjects { public class LogonParametersWithServiceUrl : AuthenticationStandardLogonParameters { public string ServiceUrl { get; set; } } }
                                    Imports DevExpress.ExpressApp.Security Namespace YourSolutionName.Module.BusinessObjects Public Class LogonParametersWithServiceUrl Inherits AuthenticationStandardLogonParameters Public Property ServiceUrl() As String End Class End Namespace

                                    2.2.  In the YourSolutionName.Mobile project, double click the MobileApplication.xx file to invoke the Application Designer, select the AuthenticationStandard component and specify your custom Logon Parameters type in the AuthenticationStandard.LogonParametersType property.

                                    2.3.  In the YourSolutionName.Module.Mobile project, create a custom Controller that will register JavaScript code for the MobileLogonController.Accept action using the RegisterClientScriptOnExecute extension method to assign the value of your custom logon parameters property to the application's ServiceUrl option on the client side right after the Logon action is executed.

                                    using DevExpress.ExpressApp; using DevExpress.ExpressApp.Actions; using DevExpress.ExpressApp.Mobile.SystemModule; using HowToChangeTheDataServiceUrl.Module.BusinessObjects; namespace HowToChangeTheDataServiceUrl.Module.Mobile.Controllers { public class MobileServiceUrlController : ObjectViewController<DetailView, LogonParametersWithServiceUrl> { protected override void OnActivated() { base.OnActivated(); MobileLogonController a = Frame.GetController<MobileLogonController>(); if (a != null) { a.AcceptAction.RegisterClientScriptOnExecute("SetServiceUrlScript", "$global.ServiceUrl = $model.CurrentObject.ServiceUrl;" + a.AcceptAction.GetProcessActionOnServerScript()); } } } }
                                    Imports DevExpress.ExpressApp Imports DevExpress.ExpressApp.Actions Imports DevExpress.ExpressApp.Mobile.SystemModule Imports HowToChangeTheDataServiceUrl.Module.BusinessObjects Namespace HowToChangeTheDataServiceUrl.Module.Mobile.Controllers Public Class MobileServiceUrlController Inherits ObjectViewController(Of DetailView, LogonParametersWithServiceUrl) Protected Overrides Sub OnActivated() MyBase.OnActivated() Dim a As MobileLogonController = Frame.GetController(Of MobileLogonController)() If a IsNot Nothing Then a.AcceptAction.RegisterClientScriptOnExecute("SetServiceUrlScript", "$global.ServiceUrl = $model.CurrentObject.ServiceUrl;" & a.AcceptAction.GetProcessActionOnServerScript()) End If End Sub End Class End Namespace

                                    2.4. In the YourSolutionName.Mobile/MobileApplication.xx file, override the MobileApplication's CreateLogonWindowControllers method (or handle the XafApplication.CreateCustomLogonWindowControllers event from other places) to add your custom Controller to the Logon window controllers collection:

                                    using System.Collections.Generic; using DevExpress.ExpressApp; //... namespace YourSolutionName.Mobile { public partial class YourSolutionNameMobileApplication : MobileApplication { protected override List<Controller> CreateLogonWindowControllers() { List<Controller> list = base.CreateLogonWindowControllers(); list.Add(this.CreateController<MobileServiceUrlController>()); return list; } //... } }
                                    Imports System.Collections.Generic Imports DevExpress.ExpressApp '... Namespace YourSolutionName.Mobile Partial Public Class YourSolutionNameMobileApplication Inherits MobileApplication Protected Overrides Function CreateLogonWindowControllers() As List(Of Controller) Dim list As List(Of Controller) = MyBase.CreateLogonWindowControllers() list.Add(Me.CreateController(Of MobileServiceUrlController)()) Return list End Function '... End Class End Namespace

                                    IMPORTANT NOTES
                                    1. In the current version, lookup editors cannot be used in the logon window. So, we suggest using the System.String type for the additional property used for storing the Data Service URL in the custom logon parameters class, at least in the current version.
                                    2.  For simplicity and demo purposes, the HowToChangeTheDataServiceUrl.Mobile project contains two data services pointing to the same MobileApplication. MobileApplication is responsible for configuring a database connection (research the MobileApplication.cs code). You cannot configure different connection strings for DataService.svc and DataService2.svc or use different MobileApplication descendants with them within the same application. Both services must use the same HowToChangeTheDataServiceUrlMobileApplication type.
                                    3. For production, you must deploy two applications separately on IIS and configure their connection strings to point to different databases. For instance, the screenshot below shows a typical deployment configuration where http://localhost/MyApp1/DataService.svc and http://localhost/MyApp2/DataService2.svc use different databases.

                                    See Also:
                                    eXpressApp Framework > Getting Started > XAF Mobile (CTP) Tutorial
                                    XAF Mobile - Overview Video
                                    FAQ: New XAF HTML5/JavaScript mobile UI (CTP)
                                    How to: Use Custom Logon Parameters and Authentication

                                Show all comments
                                • leom 06.05.2018

                                  I downloaded this example works fine in 17.x framework.

                                  i'm using 18.x and use the project updated converter to 18.x
                                  and get this message when I figure the


                                • Michael (DevExpress Support) 06.06.2018

                                  @Leo: I've created a separate ticket on your behalf (T643398: NullReferenceException in T537288 after upgrading to 18.1). It has been placed in our processing queue and will be answered shortly.

                                • Phan Sin Tian 10.11.2018

                                  Company data should be stored separately in different databases. The database (or, to be more precise, the Data Service connected to it)

                                  But I notice the examples even I use different dataservice url. the database is still the same database.

                                  Please enlighten me on what I miss. 

                                • Dennis (DevExpress) 10.12.2018

                                  @Phan Sin Tian: We'll answer this question in your original ticket: E1344 example with Mobile UI. We would kindly ask you to keep all communications on the same topic within the original thread for faster processing. Thank you for your understanding.

                                • Willem de Vries 10.12.2018

                                  That's a pity Dennis, T537288 seems to be unavailable to me.Error 404.

                                • Willem de Vries 10.12.2018

                                  At least, when i click on the link in your answer. Later i saw that it's this very same article.

                                • Dennis (DevExpress) 10.12.2018

                                  @Willem de Vries: My bad. I have updated the link. Thanks!

                                0 Solutions

                                Creation Date Importance Sort by