Hi Rob,
I've added the Reference constructor taking two refs as parameter (the
baseRef and the uriRef).
Concerning the redirection to relative URIs, we already have some logic in
place. See the current code:
public void setLocationRef(String locationUri) {
Reference baseRef = (getRequest().getResourceRef() != null) ?
getRequest()
.getResourceRef().getBaseRef()
: null;
setLocationRef(new Reference(baseRef, locationUri).getTargetRef());
}
I've made sure that this logic is invoked by the redirect*() methods taking
a String-based URI parameter.
Changes in SVN trunk. Thanks for the suggestions!
Best regards,
Jerome
> -----Message d'origine-----
> De : Rob Heittman [mailto:[EMAIL PROTECTED]
> Envoyé : dimanche 16 décembre 2007 22:37
> À : [email protected]
> Objet : Re: How to redirect to a resource?
>
> I left out a step in the first example I typed. You have to
> explicitly getTargetRef() ... I did this in the second block
> of code but omitted it in the first. So, that example, corrected is:
>
> response.redirectTemporary (
> new Reference(
> request.getResourceRef ().getParentRef().getParentRef(),
>
> "group/" + groupId
> ).getTargetRef()
> );
>
> your test case code would then be:
>
> final String baseHref = " http://localhost:8080/app/api";
> final String path = "group/1";
> final Reference ref = new Reference(new
> Reference(baseHref), path) .getTargetRef();
> System.out.println(ref);
>
> ... and that would yield the information you want.
>
> For what you are doing, getRootRef() may be much easier than
> trying to process relative references, which would require
> you to know where you are in the hierarchy.
>
> I still think it would be helpful if the Response redirect*
> methods handled relative references more transparently ... it
> is an extremely common use case to need to do this inside a
> Resource, and I feel it shouldn't be necessary to master the
> Reference API to do it correctly.
>
> Cheers,
>
> - Rob
>
>
>
> On 12/16/07, Pavel Kolesnikov <[EMAIL PROTECTED]> wrote:
>
> Thank Rob, but the constructor Reference(Reference,
> String) does not
> seem to work, it actually produces a Reference instance
> that seem to
> completely ignore the first argument.
>
>
>
>