Hi Leigh,

 

Good point, I’ve just updated the Redirector’s Javadocs (2.0 branch and SVN 
trunk) to clarify this, also adding a link to the Resolver class. 

 

I’ve also done significant enhancements of the User Guide, moving Misc/FAQ 
content into proper sections. I’ve also replaced links in the Javadocs pointing 
to the original/old tutorial you were referring to, with new ones pointing to 
the equivalent content in the User Guide. That should help Restlet API users to 
discover additional features and best practices.

 

Best regards,
Jerome
--
Restlet ~ Founder and Technical Lead ~  <http://www.restlet.org/> 
http://www.restlet.o​rg
Noelios Technologies ~  <http://www.noelios.com/> http://www.noelios.com

 

 

 

De : Tal Liron [mailto:[email protected]] 
Envoyé : mardi 5 octobre 2010 17:00
À : [email protected]
Objet : Re: Restlet 2.0 Resolver and relative references: documentation change 
request

 

Agreed! It took me a while to figure it all out. For what it's worth, I've 
documented it for the Prudence context (almost identical to pure Restlet):

 <http://threecrickets.com/prudence/manual/routing/#toc-Subsection-63> 
http://threecrickets.com/prudence/manual/routing/#toc-Subsection-63

On Mon, Oct 4, 2010 at 7:17 PM, Leigh L. Klotz, Jr. < 
<mailto:[email protected]> [email protected]> wrote:

It would nice to have the "known variables" feature of Resolver from the 
message below mentioned in tutorial section
  "10. URI rewriting and redirection" 
at   <http://www.restlet.org/documentation/2.0/tutorial#part10> 
http://www.restlet.org/documentation/2.0/tutorial#part10

and again in JavaDoc for org.restlet.routing.Redirector
   
<http://www.restlet.org/documentation/2.0/jse/api/org/restlet/routing/Redirector.html>
 
http://www.restlet.org/documentation/2.0/jse/api/org/restlet/routing/Redirector.html

because there's no way to know from looking at the tutorial or the 
documentation for Redirector that this is possible, or required.
Resolver isn't mentioned at all in Redirector JavaDoc.

In Restlet 1.1, you could do this:
  
    component.getDefaultHost().attach("/",
                                      new 
Redirector(component.getContext().createChildContext(),
                                                     "/path/to/startPage.html",
                                                     
Redirector.MODE_CLIENT_SEE_OTHER));

but in Restlet 2.0 you need to do this:
    component.getDefaultHost().attach("/",
                                      new 
Redirector(component.getContext().createChildContext(),
                                                     
"{rh}/path/to/startPage.html",
                                                     
Redirector.MODE_CLIENT_SEE_OTHER));

or else you get 
  java.lang.IllegalArgumentException: Relative references are only usable when 
a base reference is set.

Leigh.




-------- Original Message -------- 


Subject: 

Re: How to write an Universal redirector


Date: 

Wed, 24 Feb 2010 00:32:35 -0800


From: 

Thierry Boileau  <mailto:[email protected]> 
<[email protected]>


Reply-To: 

discuss  <mailto:[email protected]> <[email protected]>


To: 

 <mailto:[email protected]> <[email protected]>



Hello,

actually, the second parameter in the Redirector constructor is a template 
using a set of known variables (see [0]).
You should be able to use the shipped Redirector, as follow (or something 
similar)
new Redirector(getContext(), " <http://192.168.100.1:8080/RESTfulServices> 
http://192.168.100.1:8080/RESTfulServices{rr}";, 
Redirector.MODE_CLIENT_DISPATCHER));

Don't forget to declare the client HTTP connector on the component (such 
redirection is seen as a new client call issued by the Component). This is done 
in the web.xml file see ([1])

         <servlet>
                 [...]
                 <init-param>
                         <param-name>org.restlet.clients</param-name>
                         <param-value>HTTP</param-value>
                 </init-param>
                 [...]
         </servlet>

[0]  
<http://www.restlet.org/documentation/2.0/jse/api/org/restlet/util/Resolver.html>
 http://www.restlet.org/documentation/2.0/jse/api/org/restlet/util/Resolver.html
[1]  
<http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html>
 
http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html

Best regards,
Thierry Boileau

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2668322

Reply via email to