fatherazrael
fatherazrael

Reputation: 5977

Spring MVC: Does <Form:Label> really solves any additional purpose or is it okay to use HTML label tag?

Does Form:Label class and path solves any purpose?

<form:label class="boldText" path="comments.commentOnChild">
  <spring:message code="label.commentOnChild" />
</form:label>

What if we write statement simply in -label- tag? What additional benefits does form:label provides over HTML Label? What if i do not use Form:Label at all?

Upvotes: 0

Views: 49

Answers (2)

Chandni
Chandni

Reputation: 9

The <form:label /> tag has access to the underlying model and binding results through path variable and as such can, on error, use another style class.

The <spring:message /> tag provides you with internationalization support using Spring's MessageSource concept. The MessageSource is an interface providing functionality for retrieving messages. It closely resembles JSTL's fmt:message-tag, however, the MessageSource classes can be integrated with the Spring context. Also, the <spring:message /> tag, works with the locale support that comes with Spring.

Also you can do this without the form tag but that would mean you need to include some logic into your pages but it isn't advisable.

Upvotes: 0

Alien
Alien

Reputation: 15878

As we know that <form:label /> tag is associated to spring so it will have access to the model and binding results also and it can use another css class in case of any error.

<form:label cssClass="title" cssErrorClass="title error" path="student" />

In case of error this code will render differently than the normal label.You could also do this with normal tag but for that you need to include some logic into your pages, which will be extra you will be doing.

Upvotes: 1

Related Questions