Dear Members
I am worrking on a project, well using among many frameworks Spring MVC and Spring Web Flow, powerful sub projects of course
I did realize the particular situation about the validation object model control for each subproject, for example for Spring MVC
I used to work with
and for such view jsp I can see the error usingCode:@Component("entidadvalidator") public class EntidadValidator implements Validator{ public boolean supports(Class clazz){ return Entidad.class.isAssignableFrom(clazz); } public void validate(Object target, Errors errors){ Entidad entidad = (Entidad) target; if(entidad.getTipoEntidad().equals(MyConstansUtils.ALUMNO)){ for(String property : entidadPropertiesSiAlumno ) ValidationUtils.rejectIfEmptyOrWhitespace(errors, property, "required"); } ....
orCode:<form:errors path="*" class="error" />
Now For Spring Web Flow I have to use something likeCode:<tr> <td><spring:message code="razonEntidad" text="No deberia aparecer" /></td> <td><form:input path="razonEntidad" size="50" /></td> <td><form:errors path="razonEntidad" class="error" /></td> </tr>
The second bold part seems more verboseCode:@Component public class BookingValidator { public void validateEnterBookingDetails(Booking booking, ValidationContext context) { MessageContext messages = context.getMessageContext(); if (booking.getCheckinDate().before(today())) { messages.addMessage(new MessageBuilder().error().source("checkinDate"). defaultText("Check in date must be a future date").build()); } else if (!booking.getCheckinDate().before(booking.getCheckoutDate())) { messages.addMessage(new MessageBuilder().error().source("checkoutDate"). defaultText("Check out date must be later than check in date").build()); } } }
After to search in the Forum I can see all the error messages
Here arise some questionsCode:<c:forEach items="${flowRequestContext.messageContext.allMessages}" var="message"> ${message.text} </c:forEach>
1) Exists a unique way to write only once a validation control and be reused for these two sub projects?
2)
If this is for Spring MVC (error for a respective property or field)
What is the equivalent for Spring Web Flow?Code:<td> <form:errors path="razonEntidad" class="error" /></td> </tr>
Thanks in advanced


Reply With Quote
