|
Project Information
Members
Featured
Downloads
Links
|
RenderSnake is a Java library for creating components and pages that produce HTML using only Java. Its purpose is to support the creation of Web applications that are better maintainable, allows for easier reuse, have testable UI components and produces compact HTML in an efficient way. Example of a Spring Controller that maps the index.html to a HomePage @Controller
public class IndexAction {
@RequestMapping("/index.html")
@ResponseBody
public void home(HtmlCanvas html) throws IOException {
html.render(new MobileSiteLayoutWrapper(new HomePage()));
}
}Example of a HTML5 page wrapper and JQuery Mobile public class MobileSiteLayoutWrapper extends RenderableWrapper {
public MobileSiteLayoutWrapper(Renderable component) {
super(component);
}
@Override
public void renderOn(HtmlCanvas html) throws IOException {
html
.render(DocType.HTML5)
.html()
.head()
.title().write("renderSnake - Mobile")._title()
.render(JQueryLibrary.mobileTheme("1.0"))
.render(JQueryLibrary.core("1.6.4"))
.render(JQueryLibrary.mobile("1.0"))
._head()
.body()
.div(dataRole("page"))
.div(dataRole("header").dataTheme("b"))
.render(new PageHeader())
._div()
.div(dataRole("content").dataTheme("b"))
.render(this.component)
._div()
.div(dataRole("footer").dataTheme("b"))
.render(new PageFooter())
._div()
._div()
._body()
._html();
}
}Example of a login component public class LoginPageContent implements Renderable {
@Override
public void renderOn(HtmlCanvas html) throws IOException {// @formatter:off
html.form(action("/login").method("post").id("login-form"))
.fieldset()
.div(dataRole("fieldcontain"))
.label(for_("name")).content("Username")
.input(type("text").name("name").id("name"))
._div()
.div(dataRole("fieldcontain"))
.label(for_("password")).content("Password")
.input(type("password").name("password").id("password"))
._div()
.input(type("submit").value("Login"))
._fieldset()
._form();
}
}
|