Re: Recommended way to generate REST URLs in Wicket 6.3

2012-11-30 Thread Martin Grigorov
Hi,

Read http://wicketinaction.com/2011/07/wicket-1-5-mounting-pages/


On Fri, Nov 30, 2012 at 11:52 AM, René Vangsgaard rene.vangsga...@gmail.com
 wrote:

 Hi all

 Searching the net I found various ways to support RESTful URLs in Wicket,
 including the MixedParamUrlCodingStrategy. I am just curious if there is an
 easier way, as it looks cumbersome.

 I like the method mountPage (example in Scala below), but it does not
 generate RESTful URLs, the URL looks like this: guide//step/?3 - the
 guideId and stepNo is missing.

 What is the recommended way of generating REST URLs in Wicket 6.3?

 mountPage(/guide/${guideId}/step/${stepNo}, classOf[GuidePage])




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com http://jweekend.com/


Re: Recommended way to generate REST URLs in Wicket 6.3

2012-11-30 Thread René Vangsgaard
Thank you, but my second was more on generating REST-like URLs, not
consuming them. I have rephrased my example below.

In init:
mountPage(/guide/${guideId}/step/${stepNo}, classOf[GuidePage])

In StateLessLink.onClick:
setResponsePage(new GuidePage(1984, 1))

It generate this URL (the last number changing):
http://localhost:8080/guide//step/?3



On 30 November 2012 12:03, Martin Grigorov mgrigo...@apache.org wrote:

 Hi,

 Read http://wicketinaction.com/2011/07/wicket-1-5-mounting-pages/


 On Fri, Nov 30, 2012 at 11:52 AM, René Vangsgaard 
 rene.vangsga...@gmail.com
  wrote:

  Hi all
 
  Searching the net I found various ways to support RESTful URLs in Wicket,
  including the MixedParamUrlCodingStrategy. I am just curious if there is
 an
  easier way, as it looks cumbersome.
 
  I like the method mountPage (example in Scala below), but it does not
  generate RESTful URLs, the URL looks like this: guide//step/?3 - the
  guideId and stepNo is missing.
 
  What is the recommended way of generating REST URLs in Wicket 6.3?
 
  mountPage(/guide/${guideId}/step/${stepNo}, classOf[GuidePage])
 



 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com http://jweekend.com/



Re: Recommended way to generate REST URLs in Wicket 6.3

2012-11-30 Thread Martin Grigorov
No worries.
I still have problem to understand why people call Urls with path
parameters REST-urls. There is no problem to read query string parameters
in RESTful app.


On Fri, Nov 30, 2012 at 12:47 PM, René Vangsgaard rene.vangsga...@gmail.com
 wrote:

 Thank you, but my second was more on generating REST-like URLs, not
 consuming them. I have rephrased my example below.

 In init:
 mountPage(/guide/${guideId}/step/${stepNo}, classOf[GuidePage])

 In StateLessLink.onClick:
 setResponsePage(new GuidePage(1984, 1))

 It generate this URL (the last number changing):
 http://localhost:8080/guide//step/?3


There are two problems here.
1) encoded in the url path or query string these parameters are still
parameters
In your code about GuidePage is created without PageParameters being used,
so Wicket has no way to find values for the placeholders
Solution:
val params = new PageParameters();
params.set(guideId, 1984)
params.set(stepNo, 1)
setResponsePage(classOf[GuidePage], params)


2) the extra pageId in the query string is used internally by Wicket
It is not needed only when your page is stateless
If GuidePage has no stateful components/behaviors then all will be fine.
Set log level to DEBUG for org.apache.wicket.Page to see whether a Page is
stateful and why






 On 30 November 2012 12:03, Martin Grigorov mgrigo...@apache.org wrote:

  Hi,
 
  Read http://wicketinaction.com/2011/07/wicket-1-5-mounting-pages/
 
 
  On Fri, Nov 30, 2012 at 11:52 AM, René Vangsgaard 
  rene.vangsga...@gmail.com
   wrote:
 
   Hi all
  
   Searching the net I found various ways to support RESTful URLs in
 Wicket,
   including the MixedParamUrlCodingStrategy. I am just curious if there
 is
  an
   easier way, as it looks cumbersome.
  
   I like the method mountPage (example in Scala below), but it does not
   generate RESTful URLs, the URL looks like this: guide//step/?3 - the
   guideId and stepNo is missing.
  
   What is the recommended way of generating REST URLs in Wicket 6.3?
  
   mountPage(/guide/${guideId}/step/${stepNo}, classOf[GuidePage])
  
 
 
 
  --
  Martin Grigorov
  jWeekend
  Training, Consulting, Development
  http://jWeekend.com http://jweekend.com/
 




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com http://jweekend.com/


Re: Recommended way to generate REST URLs in Wicket 6.3

2012-11-30 Thread René Vangsgaard
Using the class and PageParameters together did it. Thanks a lot.


On 30 November 2012 13:01, Martin Grigorov mgrigo...@apache.org wrote:

 No worries.
 I still have problem to understand why people call Urls with path
 parameters REST-urls. There is no problem to read query string parameters
 in RESTful app.


 On Fri, Nov 30, 2012 at 12:47 PM, René Vangsgaard 
 rene.vangsga...@gmail.com
  wrote:

  Thank you, but my second was more on generating REST-like URLs, not
  consuming them. I have rephrased my example below.
 
  In init:
  mountPage(/guide/${guideId}/step/${stepNo}, classOf[GuidePage])
 
  In StateLessLink.onClick:
  setResponsePage(new GuidePage(1984, 1))
 
  It generate this URL (the last number changing):
  http://localhost:8080/guide//step/?3


 There are two problems here.
 1) encoded in the url path or query string these parameters are still
 parameters
 In your code about GuidePage is created without PageParameters being used,
 so Wicket has no way to find values for the placeholders
 Solution:
 val params = new PageParameters();
 params.set(guideId, 1984)
 params.set(stepNo, 1)
 setResponsePage(classOf[GuidePage], params)


 2) the extra pageId in the query string is used internally by Wicket
 It is not needed only when your page is stateless
 If GuidePage has no stateful components/behaviors then all will be fine.
 Set log level to DEBUG for org.apache.wicket.Page to see whether a Page is
 stateful and why



 
 
 
  On 30 November 2012 12:03, Martin Grigorov mgrigo...@apache.org wrote:
 
   Hi,
  
   Read http://wicketinaction.com/2011/07/wicket-1-5-mounting-pages/
  
  
   On Fri, Nov 30, 2012 at 11:52 AM, René Vangsgaard 
   rene.vangsga...@gmail.com
wrote:
  
Hi all
   
Searching the net I found various ways to support RESTful URLs in
  Wicket,
including the MixedParamUrlCodingStrategy. I am just curious if there
  is
   an
easier way, as it looks cumbersome.
   
I like the method mountPage (example in Scala below), but it does not
generate RESTful URLs, the URL looks like this: guide//step/?3 - the
guideId and stepNo is missing.
   
What is the recommended way of generating REST URLs in Wicket 6.3?
   
mountPage(/guide/${guideId}/step/${stepNo}, classOf[GuidePage])
   
  
  
  
   --
   Martin Grigorov
   jWeekend
   Training, Consulting, Development
   http://jWeekend.com http://jweekend.com/
  
 



 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com http://jweekend.com/