Announcement Announcement Module
Collapse
No announcement yet.
<form:checkbox/> BUG when 1 digit map key Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <form:checkbox/> BUG when 1 digit map key

    Here's the jsp code:
    Code:
    <c:forEach var="entry" items="${viewObj.mapObj.itemMap}"
    	varStatus="status">
    	<c:set var="linkId" value="${entry.key}"></c:set>
    	<c:set var="item" value="${entry.value}"></c:set>
    	<tr>
    		<td><form:checkbox
    			title="${linkId}"
    			path="currentItemMap['${linkId}']" value="1"/></td>
    		<td>
    		${item.attrNo}</td>
    	</tr>
    </c:forEach>
    Here's the generated html code:
    Code:
    <tr>
    	<td>
    		<input type="checkbox" value="1" title="2" name="mapObj.currentItemMap['2']" id="mapObj.currentItemMap['2']1">
    		<input type="hidden" value="on" name="_mapObj.currentItemMap['2']"></td>
    	<td>
    		8316M0680</td>
    </tr>
    <tr>
    	<td>
    		<input type="checkbox" value="1" title="1" name="mapObj.currentItemMap['1']" id="mapObj.currentItemMap['1']1">
    		<input type="hidden" value="on" name="_mapObj.currentItemMap['1']"></td>
    	<td>
    		8317M0770</td>
    </tr>
    <tr>
    	<td>
    		<input type="checkbox" checked="checked" value="1" title="12" name="mapObj.currentItemMap['12']" id="mapObj.currentItemMap['12']1">
    		<input type="hidden" value="on" name="_mapObj.currentItemMap['12']"></td>
    	<td>
    		8308M0150</td>
    </tr>
    Here's the mapObj.currentItemMap actual data: KEY/VALUE pairs
    Code:
    {2=1, 1=1, 12=1}
    Findings:
    the three (3) checkboxes must be checked but only the last one was checked.

    the only difference of the checkboxes are thier KEY.

    1st checkbox KEY is '2' (which is one digit)
    2nd checkbox KEY is '1' (which is one digit)
    3rd checkbox KEY is '12' (which is two digit)

    Anyone encountered the same problem? this is very easy to reproduce. Just provide a Map<String, String> in your jsp which the KEYs are one (1) digit.

  • #2
    not only one (1) digit, rather if one (1) character as KEY

    i tried the below case.

    Here's the mapObj.currentItemMap actual data:
    Code:
    {a=1, aa=1}
    Here's the generated html code:
    Code:
    <tr>
    	<td>
    		<input type="checkbox" value="1" title="a" name="mapObj.currentItemMap['a']" id="mapObj.currentItemMap['a']1">
    		<input type="hidden" value="on" name="_mapObj.currentItemMap['a']"></td>
    	<td>
    		8316M0680</td>
    </tr>
    <tr>
    	<td>
    		<input type="checkbox" checked="checked" value="1" title="aa" name="mapObj.currentItemMap['aa']" id="mapObj.currentItemMap['aa']1">
    		<input type="hidden" value="on" name="_mapObj.currentItemMap['aa']"></td>
    	<td>
    		8317M0770</td>
    </tr>
    the bug is, checkbox elements must be checked.
    Last edited by eros; Apr 1st, 2011, 03:50 AM.

    Comment


    • #3
      I am using 2.5.6SEC01 version, this bug was already resolved in 3.x?

      Comment


      • #4
        I accidentally discovered the problem.

        During the data binding to Map<String, String> type, single character String type was converted to Character type.

        Anyone here encountered the same phenomenon?
        Last edited by eros; Apr 6th, 2011, 02:12 AM.

        Comment


        • #5
          Overriding the data binding class or some similar approach may solve my problem.

          Anyone here, knows what class do I need to override? and functionality to override?

          Comment

          Working...
          X