validating a hashmap


Web tier: servlets, JSP, Web frameworks: validating a hashmap

  1. validating a hashmap (3 messages)


    i'm using a hashmap inside a jsp :

      <logic-el:iterate id="lineVO" collection="${cashSaleVO.lines}">
              <c:out value="${lineVO.productId}"> </c:out>
              <c:out value="${lineVO.amountA}"> </c:out>
              <c:out value="${lineVO.amountB}"> </c:out>
              <html-el:text property="unitsReturned(${lineVO.productId})" value="0"/>

    where [b]unitsReturned[/b] is a hashmap

    i'd like to validate the hashmap before sending it to the server. the values for each line shound be between [b]amountA[/b] and [b]amountB[/b] for each one

    i use validation.xml but don't know how to represent this or if it's possible. i'd rather not using javascript directly but prefer validation.xml

    thanks in advance

    Threaded Messages (3)

  2. validating a hashmap[ Go to top ]

    hashmap before sending it to the server
    how can you send a hashmap to server?

  3. validating a hashmap.[ Go to top ]

    i define a dyna action form this way:

      <form-bean name="orderForm" type="org.apache.struts.validator.DynaValidatorForm">
          <form-property name="orderLines" type="java.util.HashMap"/>
          <form-property name="clientId" type="java.lang.Long"/>

    so i use it in the jsp and, when i recibe it in my java action, i can read the data inside. i just have to take care i clean it after using otherwise i can access the jsp again and the data in the hashmap may be still there or at least it happened once to me and i think it was due to that one.

    the only problem is that i don't know how to validate it or if it's possible
  4. validating a hashmap[ Go to top ]

    I don't know of an easy way to validate an entire hashmap using standard struts validation, however you could always write your own and set the validation.xml to use it for that particular form property.

    As a side note, it would probably be better to use the JSTL forEach iterator than the struts logic iterator.

    it would be

    <c:forEach items="${cashSaleVO.lines}" var="lineVO">

    since you're already using JSTL for output during the iteration.