Thanks.. so the default option is to create such types manually.. ok..
I will follow that..
On Wed, Sep 16, 2009 at 6:22 PM, Craig McClanahan
<Craig.McClanahan_at_sun.com> wrote:
> Felipe Gaścho wrote:
>>
>> If I want to produce an output like:
>>
>> <account>
>> <id>ADK31242</id>
>> <link href="http://bank.org/account/ADK31242" rel="self"/>
>> <link rel="http://bank.org/rel/transfer"
>> type="application/vnd.bank.org.customer+xml"
>> href="http://bank.org/transfers"/>
>> <balance currency="USD">534.62</balance>
>> </account>
>>
>> Is there some special support in Jersey to produce such LINK and REL
>> elements and attributes .. ? or should I import the HTML schema or to
>> define these types by myself ?
>>
>>
>>
>>
>>
>
> There are two pieces to this puzzle.
>
> Jersey does have support for calculating what the URI value to be included
> in your link tags should be. Check out the UriBuilder[1] class in the
> JAX-RS API. It lets you build up a URI, for example, by knowing the
> resource class and path template arguments you want to use. You can also
> google "jersey uribuilder examples" for some links to sample code using
> this.
>
> Everything about converting your response entity into an XML data structure
> like this (whether it is a link or not) is totally dependent on the
> mechanism you are using to create the response. A couple of choices for
> this case:
>
> * Manually build up the XML as a string yourself, and send it as the
> response entity.
> There's nothing Jersey can really do for you here ... it doesn't pay any
> attention to
> the actual content.
>
> * Create classes for Account and Link that are annotated with JAXB
> annotations.
> In particular on the Link class, you'll want to use the annotations that
> make the
> "href" and "rel" properties come out as XML attributes, rather than as
> nested elements
> (which is the JAXB default). The Account class might have a "links"
> property of
> type List<Link> or something, which you could use to configure the links.
> Then,
> all you need is to return the Account instance as your response entity.
>
> Craig
>
> [1]
> https://jsr311.dev.java.net/nonav/releases/1.1/javax/ws/rs/core/UriBuilder.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
--
Looking for a client application for this service:
http://fgaucho.dyndns.org:8080/footprint-service/wadl