Hi all,
I'm having a hard time figuring out how to use spring validation (not commons, if that matters) on a nested property in a form.
In my application, a BlockTrade objects contains a list of BuyerSeller objects.
My form has entry fields for properties of a BlockTrade object (this is the parent) as well as properties of each of the BuyerSellers contained in the parent object.
For clarification this is what my .jsp looks like:
Code:... <spring:bind path="BlockTrade.price"> <input type="text" name="price" value="<c:out value="${status.value}"/>"/> <span class="fieldError"><c:out value="${status.errorMessage}"/></span> </spring:bind> ... ... <c:forEach var="buyerSeller" items="${BlockTrade.buyerSellers}" varStatus="status"> Quantity: <input type="text" name="buyerSellers[<c:out value="${status.index}"/>].quantity" value="<c:out value="${BlockTrade.buyerSellers[status.index].quantity}"/>" /></br> </c:forEach> ...
I have no problems validating the BlockTrade object, but I can't figure out how to validate the BuyerSeller objects.
Spring doesn't let me register a BuyerSeller validator since the BuyerSeller is not the command class:
And I get errors trying to access the child objects' properties within the validatorCode:[junit] Caused by: java.lang.IllegalArgumentException: Validator [com.boa.web.springframework.validators.BuyerSellerValidator@1759d12] does not support command class [com.boa.beans.BlockTrade]
*I used buyerSeller[0] as a test since the jsp puts out an indexed list of buyer sellers.Code:org.springframework.beans.NotReadablePropertyException: Invalid property 'buyerSeller[0]' of bean class [com.boa.beans.BlockTrade]: Property 'buyerSeller[0]' is not readable
So how should I go about doin this? Can I register a validator for a class other than the command class? Or is there a way to forward to another validator w/out registering it?
Thanks for any and all help...


Reply With Quote