Getting Parameters from URL or Request Part II [message #31247] |
Wed, 06 June 2007 04:12  |
Eclipse User |
|
|
|
Hello,
it has already been talked about that you can access parameters of the RAP
URL through ContextProvider.getRequest().getParameterMap().
I am now facing the problem, that I do not get my correct parameters of the
URL that was called originally if I use
ContextProvider.getRequest().getParameterMap() somewhere later in my
application since RAP changes the parameters for the request. I already
tried to
read the parameters in the activator as the plugin starts, but then I get a
"Context is not available...."-Exception. Then I thought that maybe I can
read the parameters initially in
the createUI method of the entry point, but that is too late.
Is there a way to get the original parameters out of the URL somehow?
My url looks like: http://localhost/rap?var1=value1&var2=value2 .
Thanks in advance,
Markus
|
|
|
|
Re: Getting Parameters from URL or Request Part II [message #31313 is a reply to message #31283] |
Wed, 06 June 2007 05:22  |
Eclipse User |
|
|
|
Thanks Frank. You were right. The getParameterMap() method returns string
arrays as values instead of simple strings. That caused the error in my
application.
Regards,
Markus
"Frank Appel" <fappel@innoopract.com> schrieb im Newsbeitrag
news:f45tb0$dur$1@build.eclipse.org...
> Hi Markus,
>
> RAP doesn't change the request parameters. It only buffers the the
> parameters in case of a additional browser-detection-request, so that they
> don't get lost for the application programmer. But with the index-template
> mechanism normally this request isn't send anymore - so you should get the
> original request object.
>
> Reading the request-values in the createUI-method works for us. If you
> want to process the request-parameters earlier you should use a
> phaselistener (before PrepareUIRoot). That's the earliest point where you
> could enter the lifecycle.
>
> The following codesnippet for the example URL
> http://localhost/rap?var1=value1&var2=value2 ...
>
> HttpServletRequest request = ContextProvider.getRequest();
> Enumeration parameterNames = request.getParameterNames();
> while( parameterNames.hasMoreElements() ) {
> String key = ( String )parameterNames.nextElement();
> System.out.println( key + ": " + request.getParameter( key ) );
> }
>
> ...produces the following console log:
> w4t_survey: true
> w4t_width: 782
> nocache: 1181120323906
> w1.bounds.width: 782
> w4t_height: 861
> var1: value1
> var2: value2
> uiRoot: w1
> requestCounter: 0
> w4t_startup: default
> w4t_scriptEnabled: true
> w4t_ajaxEnabled: true
> w1.bounds.height: 861
>
> So if you get different parameters the problem must be s.th. else. But
> actually we don't use the getParameterMap() we use getParameter() - maybe
> there is a problem with that.
>
> Ciao
> Frank
>
> "Markus Kr
|
|
|
Powered by
FUDForum. Page generated in 0.04852 seconds