Re: How to get request/page parameters from RequestCycle?

2015-01-19 Thread Daniel Stoch
Well this workaround from my previous post does not work, because this
page does not exists yet when I need to get this parameter value.

--
Daniel

On Mon, Jan 19, 2015 at 4:16 PM, Daniel Stoch daniel.st...@gmail.com wrote:
 Maybe such workaround (not very elegant though):

 app.init():
   getRequestCycleListeners().add(new PageRequestHandlerTracker());

   private Page getCurrentPage(RequestCycle requestCycle) {
 IPageRequestHandler pageRequestHandler =
 PageRequestHandlerTracker.getLastHandler(requestCycle);
 if ((pageRequestHandler != null)  (pageRequestHandler.getPage()
 instanceof Page)) {
   Page page = (Page)pageRequestHandler.getPage();
   return page;
 }
 return null;
   }

   Page page = getCurrentPage(requestCycle.getPageParameters());
   if (page != null) {
 PageParameters pageParameters =
 getCurrentPage(requestCycle.getPageParameters());
 String value = pageParameters.getString(paramName);
   } ...

 ?

 --
 Daniel

 On Mon, Jan 19, 2015 at 3:38 PM, Daniel Stoch daniel.st...@gmail.com wrote:
 Hi,

 In Wicket 1.4 I can get a page parameter value using this code:

 PageParameters pageParameters = requestCycle.getPageParameters();
 String value = pageParameters.getString(paramName);


 The problem is that in Wicket 6 there is no equivalent. I have tried
 with this solution:

 IRequestParameters requestParameters =
 requestCycle.getRequest().getRequestParameters();
 String value = requestParameters.getParameterValue(paramName).toString();

 but this does not work. These requestParameters does not contain
 parameters. I think the problem is related to url encoding strategy
 which is used. My urls are encoded like:
 somepath/param1/value1/param2/value2

 Is there another way to do this?

 --
 Best regards,
 Daniel

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to get request/page parameters from RequestCycle?

2015-01-19 Thread Daniel Stoch
On Mon, Jan 19, 2015 at 4:54 PM, Martin Grigorov mgrigo...@apache.org wrote:
 Hi,

 On Mon, Jan 19, 2015 at 4:38 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:

 Hi,

 In Wicket 1.4 I can get a page parameter value using this code:

 PageParameters pageParameters = requestCycle.getPageParameters();
 String value = pageParameters.getString(paramName);


 The problem is that in Wicket 6 there is no equivalent. I have tried
 with this solution:

 IRequestParameters requestParameters =
 requestCycle.getRequest().getRequestParameters();
 String value =
 requestParameters.getParameterValue(paramName).toString();


 request.getQueryParameters() is the equivalent, but #getRequestParameters()
 would work too because it is a mix of GET and POST parameters

But I think it does not work with UrlPathPageParametersEncoder.




 but this does not work. These requestParameters does not contain
 parameters. I think the problem is related to url encoding strategy
 which is used. My urls are encoded like:
 somepath/param1/value1/param2/value2


 Check org.apache.wicket.request.mapper.parameter.UrlPathPageParametersEncoder

Ok, but how should I get url argument?
requestCycle.getRequest().getUrl() return null for me.

Another, minor, problem is that with this solution I have a hard coded
page parameters encoder here. In previous version the code can be
universal: it does not matter which encoding strategies page is using.
For now if there will be pages with different encoding strategies this
code stops working.

--
Daniel






 Is there another way to do this?

 --
 Best regards,
 Daniel

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to get request/page parameters from RequestCycle?

2015-01-19 Thread Daniel Stoch
Sorry, my fault - I forgot to pass a parameter.
So:
  requestCycle.getRequest().getUrl()
returns full path including mountpath and parameters, eg.:
somepath/param1/value1

But if I pass this to
UrlPathPageParametersEncoder.decodePageParameters() this decodes
somepath as a first argument.


On Mon, Jan 19, 2015 at 5:12 PM, Daniel Stoch daniel.st...@gmail.com wrote:
 requestCycle.getRequest().getUrl() return null for me. - sorry, not
 null but returns only a mount path without paramname/paramvalue part.

 On Mon, Jan 19, 2015 at 5:09 PM, Daniel Stoch daniel.st...@gmail.com wrote:
 On Mon, Jan 19, 2015 at 4:54 PM, Martin Grigorov mgrigo...@apache.org 
 wrote:
 Hi,

 On Mon, Jan 19, 2015 at 4:38 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:

 Hi,

 In Wicket 1.4 I can get a page parameter value using this code:

 PageParameters pageParameters = requestCycle.getPageParameters();
 String value = pageParameters.getString(paramName);


 The problem is that in Wicket 6 there is no equivalent. I have tried
 with this solution:

 IRequestParameters requestParameters =
 requestCycle.getRequest().getRequestParameters();
 String value =
 requestParameters.getParameterValue(paramName).toString();


 request.getQueryParameters() is the equivalent, but #getRequestParameters()
 would work too because it is a mix of GET and POST parameters

 But I think it does not work with UrlPathPageParametersEncoder.




 but this does not work. These requestParameters does not contain
 parameters. I think the problem is related to url encoding strategy
 which is used. My urls are encoded like:
 somepath/param1/value1/param2/value2


 Check 
 org.apache.wicket.request.mapper.parameter.UrlPathPageParametersEncoder

 Ok, but how should I get url argument?
 requestCycle.getRequest().getUrl() return null for me.

 Another, minor, problem is that with this solution I have a hard coded
 page parameters encoder here. In previous version the code can be
 universal: it does not matter which encoding strategies page is using.
 For now if there will be pages with different encoding strategies this
 code stops working.

 --
 Daniel






 Is there another way to do this?

 --
 Best regards,
 Daniel

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to get request/page parameters from RequestCycle?

2015-01-19 Thread Daniel Stoch
Maybe such workaround (not very elegant though):

app.init():
  getRequestCycleListeners().add(new PageRequestHandlerTracker());

  private Page getCurrentPage(RequestCycle requestCycle) {
IPageRequestHandler pageRequestHandler =
PageRequestHandlerTracker.getLastHandler(requestCycle);
if ((pageRequestHandler != null)  (pageRequestHandler.getPage()
instanceof Page)) {
  Page page = (Page)pageRequestHandler.getPage();
  return page;
}
return null;
  }

  Page page = getCurrentPage(requestCycle.getPageParameters());
  if (page != null) {
PageParameters pageParameters =
getCurrentPage(requestCycle.getPageParameters());
String value = pageParameters.getString(paramName);
  } ...

?

--
Daniel

On Mon, Jan 19, 2015 at 3:38 PM, Daniel Stoch daniel.st...@gmail.com wrote:
 Hi,

 In Wicket 1.4 I can get a page parameter value using this code:

 PageParameters pageParameters = requestCycle.getPageParameters();
 String value = pageParameters.getString(paramName);


 The problem is that in Wicket 6 there is no equivalent. I have tried
 with this solution:

 IRequestParameters requestParameters =
 requestCycle.getRequest().getRequestParameters();
 String value = requestParameters.getParameterValue(paramName).toString();

 but this does not work. These requestParameters does not contain
 parameters. I think the problem is related to url encoding strategy
 which is used. My urls are encoded like:
 somepath/param1/value1/param2/value2

 Is there another way to do this?

 --
 Best regards,
 Daniel

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to get request/page parameters from RequestCycle?

2015-01-19 Thread Martin Grigorov
Hi,

On Mon, Jan 19, 2015 at 4:38 PM, Daniel Stoch daniel.st...@gmail.com
wrote:

 Hi,

 In Wicket 1.4 I can get a page parameter value using this code:

 PageParameters pageParameters = requestCycle.getPageParameters();
 String value = pageParameters.getString(paramName);


 The problem is that in Wicket 6 there is no equivalent. I have tried
 with this solution:

 IRequestParameters requestParameters =
 requestCycle.getRequest().getRequestParameters();
 String value =
 requestParameters.getParameterValue(paramName).toString();


request.getQueryParameters() is the equivalent, but #getRequestParameters()
would work too because it is a mix of GET and POST parameters



 but this does not work. These requestParameters does not contain
 parameters. I think the problem is related to url encoding strategy
 which is used. My urls are encoded like:
 somepath/param1/value1/param2/value2


Check org.apache.wicket.request.mapper.parameter.UrlPathPageParametersEncoder



 Is there another way to do this?

 --
 Best regards,
 Daniel

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: How to get request/page parameters from RequestCycle?

2015-01-19 Thread Daniel Stoch
requestCycle.getRequest().getUrl() return null for me. - sorry, not
null but returns only a mount path without paramname/paramvalue part.

On Mon, Jan 19, 2015 at 5:09 PM, Daniel Stoch daniel.st...@gmail.com wrote:
 On Mon, Jan 19, 2015 at 4:54 PM, Martin Grigorov mgrigo...@apache.org wrote:
 Hi,

 On Mon, Jan 19, 2015 at 4:38 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:

 Hi,

 In Wicket 1.4 I can get a page parameter value using this code:

 PageParameters pageParameters = requestCycle.getPageParameters();
 String value = pageParameters.getString(paramName);


 The problem is that in Wicket 6 there is no equivalent. I have tried
 with this solution:

 IRequestParameters requestParameters =
 requestCycle.getRequest().getRequestParameters();
 String value =
 requestParameters.getParameterValue(paramName).toString();


 request.getQueryParameters() is the equivalent, but #getRequestParameters()
 would work too because it is a mix of GET and POST parameters

 But I think it does not work with UrlPathPageParametersEncoder.




 but this does not work. These requestParameters does not contain
 parameters. I think the problem is related to url encoding strategy
 which is used. My urls are encoded like:
 somepath/param1/value1/param2/value2


 Check org.apache.wicket.request.mapper.parameter.UrlPathPageParametersEncoder

 Ok, but how should I get url argument?
 requestCycle.getRequest().getUrl() return null for me.

 Another, minor, problem is that with this solution I have a hard coded
 page parameters encoder here. In previous version the code can be
 universal: it does not matter which encoding strategies page is using.
 For now if there will be pages with different encoding strategies this
 code stops working.

 --
 Daniel






 Is there another way to do this?

 --
 Best regards,
 Daniel

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to get request/page parameters from RequestCycle?

2015-01-19 Thread Martin Grigorov
On Mon, Jan 19, 2015 at 6:09 PM, Daniel Stoch daniel.st...@gmail.com
wrote:

 On Mon, Jan 19, 2015 at 4:54 PM, Martin Grigorov mgrigo...@apache.org
 wrote:
  Hi,
 
  On Mon, Jan 19, 2015 at 4:38 PM, Daniel Stoch daniel.st...@gmail.com
  wrote:
 
  Hi,
 
  In Wicket 1.4 I can get a page parameter value using this code:
 
  PageParameters pageParameters = requestCycle.getPageParameters();
  String value = pageParameters.getString(paramName);
 
 
  The problem is that in Wicket 6 there is no equivalent. I have tried
  with this solution:
 
  IRequestParameters requestParameters =
  requestCycle.getRequest().getRequestParameters();
  String value =
  requestParameters.getParameterValue(paramName).toString();
 
 
  request.getQueryParameters() is the equivalent, but
 #getRequestParameters()
  would work too because it is a mix of GET and POST parameters

 But I think it does not work with UrlPathPageParametersEncoder.


Right. My fault.



 
 
 
  but this does not work. These requestParameters does not contain
  parameters. I think the problem is related to url encoding strategy
  which is used. My urls are encoded like:
  somepath/param1/value1/param2/value2
 
 
  Check
 org.apache.wicket.request.mapper.parameter.UrlPathPageParametersEncoder

 Ok, but how should I get url argument?
 requestCycle.getRequest().getUrl() return null for me.


try with request.getClientUrl();



 Another, minor, problem is that with this solution I have a hard coded
 page parameters encoder here. In previous version the code can be
 universal: it does not matter which encoding strategies page is using.
 For now if there will be pages with different encoding strategies this
 code stops working.


You are 3 years late with your feedback...Sorry.
But AFAIR 1.4 used different url coding strategies to accomplish this.
The request mapper needs to know what strategy to use when creating the url
to the page.



 --
 Daniel



 
 
 
  Is there another way to do this?
 
  --
  Best regards,
  Daniel
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: How to get request/page parameters from RequestCycle?

2015-01-19 Thread Daniel Stoch
This code is called inside custom
DefaultMapperContext.newPageInstance() implementation and in custom
IRequestMapper.mapRequest() method.

--
Daniel

On Mon, Jan 19, 2015 at 5:22 PM, Martin Grigorov mgrigo...@apache.org wrote:
 In what context do you need to extract these parameters ?
 In what class is this code ?

 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov

 On Mon, Jan 19, 2015 at 6:20 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:

 Sorry, my fault - I forgot to pass a parameter.
 So:
   requestCycle.getRequest().getUrl()
 returns full path including mountpath and parameters, eg.:
 somepath/param1/value1

 But if I pass this to
 UrlPathPageParametersEncoder.decodePageParameters() this decodes
 somepath as a first argument.


 On Mon, Jan 19, 2015 at 5:12 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:
  requestCycle.getRequest().getUrl() return null for me. - sorry, not
  null but returns only a mount path without paramname/paramvalue part.
 
  On Mon, Jan 19, 2015 at 5:09 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:
  On Mon, Jan 19, 2015 at 4:54 PM, Martin Grigorov mgrigo...@apache.org
 wrote:
  Hi,
 
  On Mon, Jan 19, 2015 at 4:38 PM, Daniel Stoch daniel.st...@gmail.com
  wrote:
 
  Hi,
 
  In Wicket 1.4 I can get a page parameter value using this code:
 
  PageParameters pageParameters = requestCycle.getPageParameters();
  String value = pageParameters.getString(paramName);
 
 
  The problem is that in Wicket 6 there is no equivalent. I have tried
  with this solution:
 
  IRequestParameters requestParameters =
  requestCycle.getRequest().getRequestParameters();
  String value =
  requestParameters.getParameterValue(paramName).toString();
 
 
  request.getQueryParameters() is the equivalent, but
 #getRequestParameters()
  would work too because it is a mix of GET and POST parameters
 
  But I think it does not work with UrlPathPageParametersEncoder.
 
 
 
 
  but this does not work. These requestParameters does not contain
  parameters. I think the problem is related to url encoding strategy
  which is used. My urls are encoded like:
  somepath/param1/value1/param2/value2
 
 
  Check
 org.apache.wicket.request.mapper.parameter.UrlPathPageParametersEncoder
 
  Ok, but how should I get url argument?
  requestCycle.getRequest().getUrl() return null for me.
 
  Another, minor, problem is that with this solution I have a hard coded
  page parameters encoder here. In previous version the code can be
  universal: it does not matter which encoding strategies page is using.
  For now if there will be pages with different encoding strategies this
  code stops working.
 
  --
  Daniel
 
 
 
 
 
 
  Is there another way to do this?
 
  --
  Best regards,
  Daniel
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to get request/page parameters from RequestCycle?

2015-01-19 Thread Martin Grigorov
In what context do you need to extract these parameters ?
In what class is this code ?

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Jan 19, 2015 at 6:20 PM, Daniel Stoch daniel.st...@gmail.com
wrote:

 Sorry, my fault - I forgot to pass a parameter.
 So:
   requestCycle.getRequest().getUrl()
 returns full path including mountpath and parameters, eg.:
 somepath/param1/value1

 But if I pass this to
 UrlPathPageParametersEncoder.decodePageParameters() this decodes
 somepath as a first argument.


 On Mon, Jan 19, 2015 at 5:12 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:
  requestCycle.getRequest().getUrl() return null for me. - sorry, not
  null but returns only a mount path without paramname/paramvalue part.
 
  On Mon, Jan 19, 2015 at 5:09 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:
  On Mon, Jan 19, 2015 at 4:54 PM, Martin Grigorov mgrigo...@apache.org
 wrote:
  Hi,
 
  On Mon, Jan 19, 2015 at 4:38 PM, Daniel Stoch daniel.st...@gmail.com
  wrote:
 
  Hi,
 
  In Wicket 1.4 I can get a page parameter value using this code:
 
  PageParameters pageParameters = requestCycle.getPageParameters();
  String value = pageParameters.getString(paramName);
 
 
  The problem is that in Wicket 6 there is no equivalent. I have tried
  with this solution:
 
  IRequestParameters requestParameters =
  requestCycle.getRequest().getRequestParameters();
  String value =
  requestParameters.getParameterValue(paramName).toString();
 
 
  request.getQueryParameters() is the equivalent, but
 #getRequestParameters()
  would work too because it is a mix of GET and POST parameters
 
  But I think it does not work with UrlPathPageParametersEncoder.
 
 
 
 
  but this does not work. These requestParameters does not contain
  parameters. I think the problem is related to url encoding strategy
  which is used. My urls are encoded like:
  somepath/param1/value1/param2/value2
 
 
  Check
 org.apache.wicket.request.mapper.parameter.UrlPathPageParametersEncoder
 
  Ok, but how should I get url argument?
  requestCycle.getRequest().getUrl() return null for me.
 
  Another, minor, problem is that with this solution I have a hard coded
  page parameters encoder here. In previous version the code can be
  universal: it does not matter which encoding strategies page is using.
  For now if there will be pages with different encoding strategies this
  code stops working.
 
  --
  Daniel
 
 
 
 
 
 
  Is there another way to do this?
 
  --
  Best regards,
  Daniel
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: How to get request/page parameters from RequestCycle?

2015-01-19 Thread Daniel Stoch
I have found another solution: in my scenario I can get parameters
from DefaultMapperContext.
newPageInstance(). Thanks for your help and tips.

--
Daniel

On Mon, Jan 19, 2015 at 5:44 PM, Daniel Stoch daniel.st...@gmail.com wrote:
 This code is called inside custom
 DefaultMapperContext.newPageInstance() implementation and in custom
 IRequestMapper.mapRequest() method.

 --
 Daniel

 On Mon, Jan 19, 2015 at 5:22 PM, Martin Grigorov mgrigo...@apache.org wrote:
 In what context do you need to extract these parameters ?
 In what class is this code ?

 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov

 On Mon, Jan 19, 2015 at 6:20 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:

 Sorry, my fault - I forgot to pass a parameter.
 So:
   requestCycle.getRequest().getUrl()
 returns full path including mountpath and parameters, eg.:
 somepath/param1/value1

 But if I pass this to
 UrlPathPageParametersEncoder.decodePageParameters() this decodes
 somepath as a first argument.


 On Mon, Jan 19, 2015 at 5:12 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:
  requestCycle.getRequest().getUrl() return null for me. - sorry, not
  null but returns only a mount path without paramname/paramvalue part.
 
  On Mon, Jan 19, 2015 at 5:09 PM, Daniel Stoch daniel.st...@gmail.com
 wrote:
  On Mon, Jan 19, 2015 at 4:54 PM, Martin Grigorov mgrigo...@apache.org
 wrote:
  Hi,
 
  On Mon, Jan 19, 2015 at 4:38 PM, Daniel Stoch daniel.st...@gmail.com
  wrote:
 
  Hi,
 
  In Wicket 1.4 I can get a page parameter value using this code:
 
  PageParameters pageParameters = requestCycle.getPageParameters();
  String value = pageParameters.getString(paramName);
 
 
  The problem is that in Wicket 6 there is no equivalent. I have tried
  with this solution:
 
  IRequestParameters requestParameters =
  requestCycle.getRequest().getRequestParameters();
  String value =
  requestParameters.getParameterValue(paramName).toString();
 
 
  request.getQueryParameters() is the equivalent, but
 #getRequestParameters()
  would work too because it is a mix of GET and POST parameters
 
  But I think it does not work with UrlPathPageParametersEncoder.
 
 
 
 
  but this does not work. These requestParameters does not contain
  parameters. I think the problem is related to url encoding strategy
  which is used. My urls are encoded like:
  somepath/param1/value1/param2/value2
 
 
  Check
 org.apache.wicket.request.mapper.parameter.UrlPathPageParametersEncoder
 
  Ok, but how should I get url argument?
  requestCycle.getRequest().getUrl() return null for me.
 
  Another, minor, problem is that with this solution I have a hard coded
  page parameters encoder here. In previous version the code can be
  universal: it does not matter which encoding strategies page is using.
  For now if there will be pages with different encoding strategies this
  code stops working.
 
  --
  Daniel
 
 
 
 
 
 
  Is there another way to do this?
 
  --
  Best regards,
  Daniel
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org