Deze site maakt gebruik van cookies. Klik hier voor meer info.Deze melding niet meer tonen. X

Vince's xwork log

About software and other stuff






Spring project part 2: View Layer

First an update regarding the Spring project part 1: Modelling bit. As it turns out Spring provides the 'Generic Repository' natively, so with some configuration we can get rid of the bottom class.

Now for the view layer; I looked into the Thymeleaf library and it looks very promising.
Thymeleaf is a Java library. It is an XML / XHTML / HTML5 template engine (extensible to other formats) that can work both in web and non-web environments. It is better suited for serving XHTML/HTML5 at the view layer of web applications, but it can process any XML file even in offline environments.
It uses 'templates' to transform the data into the form you desire, a bit like xslt works, but you can choose almost any output format.
If you choose an html based front-end, you can design the pages off-line, ideal for example when an external webdesigner is responsible for the web-interface. Another advantage is that Thymeleaf allows you to JUnit test the view layer as well. As with all the Java libraries choosing the right target environment java version can be a bit tricky, but I have high hopes I can sort it out.

@Test
public void contact() throws Exception {
mvc.perform(get("/contactlist"))
.andExpect(status().isOk())
.andExpect(content().string(containsString("John")))
.andExpect(content().string(containsString("Jane")));
}