E has posted 5 posts at DZone. View Full User Profile

renderSnake 1.5 released

02.28.2012
| 1360 views |
  • submit to reddit

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.

This is how a simple LoginFrom component looks like. Element and attributes are methods that you can write in a builder-like or fluent style.
//------------------------------------------------------------
public class LoginForm implements Renderable {

    public void renderOn(HtmlCanvas html) throws IOException {
        
        html
            .form(action("login").method("post").id("login-form"))
            .fieldset()
                .div()
                    .label(for_("name")).content("Username")                    
                    .input(type("text").name("name").id("name"))                    
                ._div()
                .div()
                    .label(for_("password")).content("Password")
                    .input(type("password").name("password").id("password"))                    
                ._div()
                .input(type("submit").value("Login"))
            ._fieldset()
            ._form(); 
    }
}
//------------------------------------------------------------

This release is leaner because

  • it removes some required dependencies  (apache commons-io, antlr stringtemplate)
  • it removes its own servlet for dispatching (spring, guice or your likes are better in this job)
  • it removes its own template encapsulation for antlr stringtemplate (if you really need templates then choose your own)

and is faster because bottlenecks found in profiling are taken care of and xml escaping is now open-coded.

This project is hosted at rendersnake.googlecode.com and has it own home on rendersnake.org (powered by rendersnake itself). Another showcase is found at 6hoek.com

0
Published at DZone with permission of its author, E Micklei.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)