Page tree
Skip to end of metadata
Go to start of metadata

Throughout the following pages, this example will be used to show how Rabbtor improves the model localization and labeling in a Spring application. 

Below is a couple of interrelated model messages which we validate with JSR 303 validation annotations:

The example is written in Groovy but Java version will be the same only with additional get/set methods.  


Command objects


class RegisterCommand

    String name

    Long departmentId

    AddressCommand address

    List<AddressCommand> addresses = []

        // Add one address to be displayed on form
        addresses.add( new AddressCommand())

class AddressCommand

    String zipcode



And below is the register.jsp file which holds a form to fill in the RegisterCommand command object.


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="" %>
<%@ taglib prefix="c" uri="" %>

<form:form modelAttribute="registerCommand" >

        <label for="name" >Name</label>
    		<form:input path="name" />
    		<form:errors path="name" />

        <label for="department" >Department</label>
	    <form:input path="department" />
    		<form:errors path="department" />

    <c:forEach items="${addCommand.addresses}" var="address" varStatus="i" >
        <h5>Address: ${i.index}</h5>
        <label for="addresses[${i.index}].zipcode" >Zipcode</label>
        <form:input path="addresses[${i.index}].zipcode" />

    <input type="submit" value="Submit" />


And here is the file for some basic localization of error messages:


NotEmpty={0} can not be empty.
NotNull={0} can not be null.

  • No labels