I need to add links to my resteasy api xml and json output.
So I wrote a JAXB AtomLink class as follows
package samples;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="link", namespace="http://www.w3.org/2005/Atom")
public class AtomLink {
private String rel;
private String href;
private String type;
public AtomLink() {}
public AtomLink(String rel, String href, String type) {
this.rel = rel;
this.href = href;
this.type = type;
}
public AtomLink(String rel, String href) {
this(rel,href,"application/xml");
}
@XmlAttribute
public String getRel() {
return rel;
}
public void setRel(String rel) {
this.rel = rel;
}
@XmlAttribute
public String getHref() {
return href;
}
public void setHref(String href) {
this.href = href;
}
@XmlAttribute
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
and set the link values in my JAXB xml or json object.
I got the output as follows. But the links are not clickable.
output:
<data xmlns:ns2="http://www.w3.org/2005/Atom">
<bucket id="2" name="2012-APR-09 12:05 AM">
<av_data unit="percent" value="100"/>
<data_count unit="#" value="10"/>
<pf_data unit="seconds" value="4.618"/>
</bucket>
<ns2:link href="http://localhost:8080/webapp/api/getrawdata?start=3&size=2" rel="next" type="application/xml"/>
</data>
What should i do to make the links clickable.
Thanks in advance.
Anitha
XML and JSON are just text based representations of data. The ability to click on a link depends upon the browser you are using to view the data ability to recognize a portion of that text as a link and render it as a hyperlink.