You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Ghaznavi, Syed" <sy...@fmr.com> on 2008/04/08 15:29:16 UTC

Commons Validator Issue with Collections

It's a question regarding commons validator api, wherein i am trying to
validate an input request form (xml-request) which contains a collection
of
items...like

<OrdersInputRequest>
  <Order>
     <OrderId>222</OderId>
     <OrderDate>04/04/2004</OrderDate>
  </Order>
   <Order>
     <OrderId>223</OderId>
     <OrderDate>04/04/2004</OrderDate>
   </Order>
</OrderInputRequest>

What would be the valid format for the commons-validator form to
validate
this input request? Since there can be any number of Orders
(java.util.ArrayList) in the request and all the items have the same
validation.
I looked at the examples on the project but couldn't find any
solution...

*     <formset>
       <form name="OrdersRequestValidationForm">
          <field property="OrderId" type="Integer" depends="required">
</field>
          <field property="OrderDate" type="String" depends="required">
</field>
       </form>
    </formset> *

Any assistance on this is appreciated..

Thanks!

--Syed Ghaznavi

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Commons Validator Issue with Collections

Posted by Laurie Harper <la...@holoweb.net>.
Neither Commons Validator nor Struts knows how to process XML requests 
like that out of the box. Assuming Struts 1, the answer is that you will 
have to write your own logic to populate the form bean from the XML 
request, after which validation can be performed the same as you would 
with a regular request.

L.

Ghaznavi, Syed wrote:
> It's a question regarding commons validator api, wherein i am trying to
> validate an input request form (xml-request) which contains a collection
> of
> items...like
> 
> <OrdersInputRequest>
>   <Order>
>      <OrderId>222</OderId>
>      <OrderDate>04/04/2004</OrderDate>
>   </Order>
>    <Order>
>      <OrderId>223</OderId>
>      <OrderDate>04/04/2004</OrderDate>
>    </Order>
> </OrderInputRequest>
> 
> What would be the valid format for the commons-validator form to
> validate
> this input request? Since there can be any number of Orders
> (java.util.ArrayList) in the request and all the items have the same
> validation.
> I looked at the examples on the project but couldn't find any
> solution...
> 
> *     <formset>
>        <form name="OrdersRequestValidationForm">
>           <field property="OrderId" type="Integer" depends="required">
> </field>
>           <field property="OrderDate" type="String" depends="required">
> </field>
>        </form>
>     </formset> *
> 
> Any assistance on this is appreciated..
> 
> Thanks!
> 
> --Syed Ghaznavi


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org