fixed URL parameters access in web UI (caused by changes RAP 3.0)
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 8 Sep 2016 13:09:11 +0000 (16:09 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 8 Sep 2016 13:09:11 +0000 (16:09 +0300)
webui/webapp/Core/src/org/netxms/ui/eclipse/console/Application.java
webui/webapp/Core/src/org/netxms/ui/eclipse/console/ApplicationWorkbenchAdvisor.java
webui/webapp/Core/src/org/netxms/ui/eclipse/console/ApplicationWorkbenchWindowAdvisor.java

index ce96e4c..49c00c7 100644 (file)
@@ -25,6 +25,7 @@ import org.eclipse.equinox.app.IApplication;
 import org.eclipse.equinox.app.IApplicationContext;
 import org.eclipse.rap.rwt.RWT;
 import org.eclipse.rap.rwt.client.service.ClientInfo;
+import org.eclipse.rap.rwt.client.service.StartupParameters;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.application.WorkbenchAdvisor;
@@ -43,7 +44,7 @@ public class Application implements IApplication
         */
        public Object start(IApplicationContext context) throws Exception
        {
-               String lang = RWT.getRequest().getParameter("lang"); //$NON-NLS-1$
+               String lang = getParameter("lang"); //$NON-NLS-1$
                if (lang != null)
                        RWT.setLocale(new Locale(lang));
                
@@ -91,4 +92,16 @@ public class Application implements IApplication
        {
                // Do nothing
        }
+       
+       /**
+        * Get application's parameter (passed as part of URL)
+        * 
+        * @param name parameter's name
+        * @return parameter's value or null if not found
+        */
+       public static String getParameter(final String name)
+       {
+      StartupParameters sp = RWT.getClient().getService(StartupParameters.class);
+      return (sp != null) ? sp.getParameter(name) : null;
+       }
 }
index 069b33f..c3d1601 100644 (file)
@@ -140,26 +140,26 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor
                final Properties properties = new AppPropertiesLoader().load();
                
                String password = "";
-               boolean autoLogin = (RWT.getRequest().getParameter("auto") != null); //$NON-NLS-1$
+               boolean autoLogin = (Application.getParameter("auto") != null); //$NON-NLS-1$
                
-               String ssoTicket = RWT.getRequest().getParameter("ticket");
+               String ssoTicket = Application.getParameter("ticket");
                if (ssoTicket != null) 
                {
                        autoLogin = true;
-                       String server = RWT.getRequest().getParameter("server"); //$NON-NLS-1$
+                       String server = Application.getParameter("server"); //$NON-NLS-1$
                        if (server == null)
                                server = properties.getProperty("server", "127.0.0.1"); //$NON-NLS-1$ //$NON-NLS-2$
                        success = connectToServer(server, null, ssoTicket);
                }
                else if (autoLogin) 
                {
-                       String server = RWT.getRequest().getParameter("server"); //$NON-NLS-1$
+                       String server = Application.getParameter("server"); //$NON-NLS-1$
                        if (server == null)
                                server = properties.getProperty("server", "127.0.0.1"); //$NON-NLS-1$ //$NON-NLS-2$
-                       String login = RWT.getRequest().getParameter("login"); //$NON-NLS-1$
+                       String login = Application.getParameter("login"); //$NON-NLS-1$
                        if (login == null)
                                login = "guest";
-                       password = RWT.getRequest().getParameter("password"); //$NON-NLS-1$
+                       password = Application.getParameter("password"); //$NON-NLS-1$
                        if (password == null)
                                password = "";
                        success = connectToServer(server, login, password);
index 36c87d2..2243891 100644 (file)
@@ -148,7 +148,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor
        @Override
    public void postWindowOpen()
    {
-      String dashboardId = RWT.getRequest().getParameter("dashboard"); //$NON-NLS-1$
+      String dashboardId = Application.getParameter("dashboard"); //$NON-NLS-1$
       if (dashboardId != null)
          showDashboard(dashboardId);
    }