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

Now let's change the example form given in Example Command Object and Form 

First let's put additional message keys to our file:

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

And change the form to use Rabbtor's custom label JSP tag:



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

        <form:form modelAttribute="registerCommand" >

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

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

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

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






So Rabbtor puts labels for the properties even for the nested ones using the same message codes in error message display names.

Till now, everything looks good. But we didn't use the model metadata fully yet. As we said, we have a @DisplayName annotation. Now let's see how it works.



  • No labels