users@jersey.java.net

Re: Re: [Jersey] Re: Alternate to HttpRequestContext#getAcceptableMediaType

From: John Lister <john.lister_at_kickstone.com>
Date: Wed, 27 Oct 2010 19:21:56 +0100

Just be careful, when you build variant list as described in the linked
presentation you need to call add() before build() to generate the
variant combinations for build to return. Slightly odd syntax and caught
me out the first time.

eg:
List<Variant> vs = Variant.mediaTypes("a/xml", "a/json").languages("en",
"fr").build();
becomes
List<Variant> vs = Variant.mediaTypes("a/xml", "a/json").languages("en",
"fr").add().build();

John

On 19:59, Imran M Yousuf wrote:
> On Wed, Oct 27, 2010 at 3:26 PM, Paul Sandoz<Paul.Sandoz_at_oracle.com> wrote:
>> <snip />
>>
>> In that case i would recommend using the Variant support.
>>
>> See the JavaOne 2010 presentation for how it works:
>>
>> http://blogs.sun.com/sandoz/resource/J1-2010-JAX-RS-S313265.pdf
>>
> Thanks a lot Paul, exactly what I was looking for.
>
> Regards,
>
> Imran
>
>> Paul.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>
>