Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 404546

Summary: Request parameters are empty on page reload
Product: [RT] RAP Reporter: Ingo Meyer <ingo.meyer>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: ivan, jeick
Version: 2.1   
Target Milestone: 2.1 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard: protocol
Attachments:
Description Flags
Proposed patch none

Description Ingo Meyer CLA 2013-03-28 07:26:05 EDT
I have created a RAP application with

<extension point="org.eclipse.rap.ui.entrypoint">
	<entrypoint class="xxx.WorkbenchImpl" id="xx" path="/xxx"/>
</extension>

and I'm calling that with "http://127.0.0.1:10080/xxx?param1=0"

But in the EntryPoint#createUI I just get an empty parameter map with "RWT.getRequest().getParameterMap()"???

As this was working with 2.0.0 I assume it is a bug
Now I'm on 2.1M1.

Any suggestions?
Comment 1 Ivan Furnadjiev CLA 2013-03-28 07:50:54 EDT
Ingo, just checked against git master with Controls and Workbench Demo and it's working for me. Both RWT.getRequest().getParameterMap() and RWT.getRequest().getParameter( String ) are working as expected.
Comment 2 Ingo Meyer CLA 2013-03-28 09:14:16 EDT
Hmm, as this is the very first line of my application, I'm lost... :(

Any ideas what I can do for debugging?
Comment 3 Ivan Furnadjiev CLA 2013-03-28 09:24:01 EDT
(In reply to comment #2)
> Hmm, as this is the very first line of my application, I'm lost... :(
Please create a simple snippet/project that fails for you and attach it to the bug. Than I will try to reproduce and debug it. If some additional steps are needed to reproduce it (browser, reload (F5)) please describe them.
Comment 4 Ingo Meyer CLA 2013-03-28 15:18:51 EDT
No, not for me...

I added the following line at the very first one in org.eclipse.rap.demo.DemoWorkbench (2.1.0.20130226-1507):

final Map<String, String[]> params = RWT.getRequest().getParameterMap();

When I debug the demo with

http://127.0.0.1:52835/rapdemo/workbench?param1=0

the params map is empty :(

So what can I do wrong? It must be a RAP bug, as it was working before with 2.0.
I have absolutely no idea...


/*******************************************************************************
 * Copyright (c) 2002, 2012 Innoopract Informationssysteme GmbH and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Innoopract Informationssysteme GmbH - initial API and implementation
 *    EclipseSource - ongoing development
 ******************************************************************************/
package org.eclipse.rap.demo;

import java.util.Map;

import org.eclipse.rap.demo.presentation.DemoPresentationWorkbenchAdvisor;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.application.EntryPoint;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.internal.util.PrefUtil;
import org.eclipse.ui.preferences.ScopedPreferenceStore;

public class DemoWorkbench
	implements EntryPoint
{
	private static final String DEMO_PRESENTATION = "org.eclipse.rap.demo.presentation";
	
	public int createUI()
	{
		final Map<String, String[]> params = RWT.getRequest().getParameterMap();
		final ScopedPreferenceStore prefStore = (ScopedPreferenceStore) PrefUtil.getAPIPreferenceStore();
		final String keyPresentationId = IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID;
		final String presentationId = prefStore.getString( keyPresentationId );
		WorkbenchAdvisor worbenchAdvisor = new DemoWorkbenchAdvisor();
		if (DEMO_PRESENTATION.equals( presentationId ))
			worbenchAdvisor = new DemoPresentationWorkbenchAdvisor();
		final Display display = PlatformUI.createDisplay();
		final int result = PlatformUI.createAndRunWorkbench( display, worbenchAdvisor );
		display.dispose();
		return result;
	}
}
Comment 5 Ivan Furnadjiev CLA 2013-03-29 03:11:35 EDT
(In reply to comment #4)
> No, not for me...
Strange... I did the same in org.eclipse.rap.demo.DemoWorkbench (http://127.0.0.1:8080/rapdemo/workbench?param1=0):
...
public int createUI() {
    final Map<String, String[]> params = RWT.getRequest().getParameterMap();
    System.out.println( "size: " + params.size() );
    System.out.println( "param1: " + params.get( "param1" )[ 0 ] );
    ScopedPreferenceStore prefStore = ( ScopedPreferenceStore )PrefUtil.getAPIPreferenceStore();
...
the output is: 
osgi> size: 1
param1: 0
I've tested it in Firefox, Cherome, IE10 and Opera... with RAP from master. You could put a break point in LifeCycleServiceHandler#handleGetRequest (line 85) and then in LifeCycleServiceHandler#handlePostRequest (line 108). This is the place where the parameters from the get request are made available in the next post requests.
Comment 6 Ingo Meyer CLA 2013-03-29 04:29:43 EDT
(In reply to comment #5)

Ok, now it gets really strange: each second call has an empty parameter map via "RWT.getRequest().getParameterMap()" while the parameters in LifeCycleServiceHandler#handleGetRequest (line 84) is never empty !!!?

I could reproduce this if I hust hit enter in the browser url-bar and look at the maps in LCSH and the DemoWorkbench. With 

		System.out.println( "============= " );
		System.out.println( "size: " + params.size() );
		System.out.println( "param1: " + params.get( "param1" )[ 0 ] );

the following is the output (Each second request (hitting enter always )) will give an http error 500:


============= 
size: 0
============= 
size: 2
param1: 55
============= 
size: 0
============= 
size: 2
param1: 55
============= 
size: 0
============= 
size: 2
param1: 55
============= 
size: 0
============= 
size: 2
param1: 55
============= 
size: 0
============= 
size: 2
param1: 55


Seems to be something with a buffer or an open session or the new UI-session thing. In RequestParameterBuffer#store (35ff) I see some comments about open bugs...

Now I'm sure it is not me entering a wrong url :-)

Can you reproduce it, too?
Comment 7 Ivan Furnadjiev CLA 2013-03-29 04:59:19 EDT
Yes... now I can... it is related to the new feature (bug 284273) implemented in 2.1M1. When page is reloaded we have:
1. GET request with the parameters - stored in the uiSession
2. POST request that kills the session (as a result of unload of the old page) - all parameters are gone
3. initial POST request that creates a new session - and call EntryPoint#createUI() with empty parameters map
I think the solution is to not keep the url parameters in the uiSession, but maybe in the RWTServlet.
Comment 8 Ivan Furnadjiev CLA 2013-03-29 05:12:11 EDT
Or even better... send URL parameters with the first POST request (in json message head) and remove RequestParameterBuffer and all the related code.
Comment 9 Ivan Furnadjiev CLA 2013-03-29 09:30:23 EDT
Created attachment 229185 [details]
Proposed patch

In this patch the query string is send and process on the server in the first POST request. Thus, one more place where the UI session is needed in the GET request is removed. No more parameters buffering on the server.
Comment 10 Ivan Furnadjiev CLA 2013-04-10 04:57:18 EDT
Fixed with commit 59b13ef7ac06e6b081f907955ee156e90a6563ed. Parameters are sent in the first POST request in the JSON head as parameter "queryString".
Comment 11 Ivan Furnadjiev CLA 2013-04-19 13:19:59 EDT
*** Bug 406110 has been marked as a duplicate of this bug. ***