|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.rexsl.page.PageBuilder
public final class PageBuilder
Page builder.
First, you should create a base class, which will be used by all pages. (they all will inherit it). The base class should be JAXB annotated, for example:
@XmlRootElement(name = "page")
public class MyPage extends BasePage {
public String title;
public BasePage title(String text) {
this.title = text;
}
@XmlElement
public String getTitle() {
return this.title;
}
}
Then, in JAX-RS resource you instantiate and extend this class with
application/request specific content (we think that suffix Rs
is a good notation for all JAX-RS resources):
@Path("/")
public class MainRs {
@GET
@Produces(MediaTypes.APPLICATION_XML)
public MyPage front() {
return new PageBuilder()
.stylesheet("/xsl/front.xsl")
.build(MyPage.class)
.append(new JaxbBundle("score", 2))
.title("Hello, world!");
}
}
That's it. The XML produced by JAX-RS and JAXB will look like:
<?xml version="1.0" ?> <?xml-stylesheet type='text/xsl' href='/xsl/front.xsl'?> <page> <score>2</score> <title>Hello, world!</title> </page>
We recommend to extend BasePage, since it already implements
a few most popular and necessary methods and properties.
The class is mutable and thread-safe.
BasePage,
JaxbGroup,
JaxbBundle| Constructor Summary | |
|---|---|
PageBuilder()
|
|
| Method Summary | ||
|---|---|---|
|
build(Class<T> base)
Create new class. |
|
PageBuilder |
schema(String name)
Configure the schema to be used. |
|
PageBuilder |
stylesheet(String uri)
Configure the stylesheet to be used. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PageBuilder()
| Method Detail |
|---|
public PageBuilder stylesheet(@NotNull
String uri)
uri - The URI of the stylesheet
public PageBuilder schema(@NotNull
String name)
name - Name of schema
public <T> T build(@NotNull
Class<T> base)
T - The type of result expectedbase - Parent class, which will be inherited
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||