Announcement Announcement Module
Collapse
No announcement yet.
need help with validation of nested properties in a form Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • need help with validation of nested properties in a form

    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&#58;bind path="BlockTrade.price">
    	<input type="text" name="price" value="<c&#58;out value="$&#123;status.value&#125;"/>"/> 
    	<span class="fieldError"><c&#58;out value="$&#123;status.errorMessage&#125;"/></span>
    </spring&#58;bind>
    ...
    
    
    
    ...
    	<c&#58;forEach var="buyerSeller" items="$&#123;BlockTrade.buyerSellers&#125;" varStatus="status">
    		Quantity&#58; <input type="text" name="buyerSellers&#91;<c&#58;out value="$&#123;status.index&#125;"/>&#93;.quantity" value="<c&#58;out value="$&#123;BlockTrade.buyerSellers&#91;status.index&#93;.quantity&#125;"/>" /></br>
    	</c&#58;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:
    Code:
        &#91;junit&#93; Caused by&#58; java.lang.IllegalArgumentException&#58; Validator &#91;[email protected]12&#93; does not support command class &#91;com.boa.beans.BlockTrade&#93;
    And I get errors trying to access the child objects' properties within the validator
    Code:
    org.springframework.beans.NotReadablePropertyException&#58; Invalid property 'buyerSeller&#91;0&#93;' of bean class &#91;com.boa.beans.BlockTrade&#93;&#58; Property 'buyerSeller&#91;0&#93;' is not readable
    *I used buyerSeller[0] as a test since the jsp puts out an indexed list of buyer sellers.




    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...
Working...
X