Is it possible to associate an arbitrary css element class with a binding state model?
<form:form method="post" commandName="authForm" action="authenticate">
<div id="login-error" class="control-group">
<label>Login</label>
<form:input path="name" />
<span class="help-inline"><form:errors path="name" /></span>
</div>
<div class="control-group">
<label>Password</label>
<form:input path="password" />
<span class="help-inline"><form:errors path="password" /></span>
</div>
<input type="submit" />
</form:form>
In this piece of code, I need to manage the class login-erroruntil control-groupwhen there are no errors and control-group errorwhen there is (the same idea for the second control-group).
What is the general solution here?
Update
Here is what I need when there is no binding error:
<div class="control-group">
<label>Login</label>
<form:input path="name" />
<span class="help-inline"><form:errors path="name" /></span>
</div>
Here is what I need when there is a binding error:
<div class="control-group error">
<label>Login</label>
<form:input path="name" />
<span class="help-inline"><form:errors path="name" /></span>
</div>
Looking for a solution.
source
share