Announcement Announcement Module
Collapse
No announcement yet.
Binding maps Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding maps

    Hi all,

    I'm developing a webapp using Spring. Everything's just fine, but I'm unable to solve the following issue:

    I have a bean "document", which have a property which in turn is a map that contains other objects (all of the same type).

    I'm unable to bind this map to a form.
    Code:
    			<c&#58;forEach var="caracteristica" items="$&#123;document.caracteristiques&#125;">
    				<tr>
    					<td><c&#58;out value="$&#123;caracteristica.value.nom&#125;"/></td>
    					<td>
    Debug <c&#58;out value="document.caracteristiques&#91;$&#123;caracteristica.key&#125;&#93;.valor"/>
    						<spring&#58;bind path="document.caracteristiques&#91;$&#123;caracteristica.key&#125;&#93;.valor">
    <c&#58;out value="$&#123;staus&#125;"/>
    							<input type="text" name="<c&#58;out value="$&#123;staus.expression&#125;"/>"
    											   value="<c&#58;out value="$&#123;staus.value&#125;"/>"/>
    						</spring&#58;bind>
    					</td>
    				</tr>
    			</c&#58;forEach>
    Both status.expression and .value return nothing, not even an error.

    While I can use "caracteristica.nom" to access a property of the map, I cannot use document.caracteristiques[${caracteristica.key}].nom.

    What may I be doing wrong ? I've been searching this forum to find an answer to no avail.

    Best regards a thanks for your time,
    Esteve

  • #2
    What is the data type of the key of your map 'caracteristiques'? Spring's BeanWrapperImpl seems to work on maps with keys of String type only.

    Sanjiv

    Comment


    • #3
      You must change your example a little:

      Code:
       <c&#58;forEach var="formaPamento" items="$&#123;formaPamentos&#125;">
           <c&#58;if test="$&#123;movimentoEstoque.formaPagamento == formaPamento.key&#125;">
      	  <option selected="<c&#58;out value="$&#123;movimentoEstoque.formaPagamento&#125;"/>" value="<c&#58;out value="$&#123;formaPamento.key&#125;"/>"><c&#58;out value="$&#123;formaPamento.value&#125;"/></option>
           </c&#58;if>
           <c&#58;if test="$&#123;movimentoEstoque.formaPagamento != formaPamento.key&#125;">
      	  <option value="<c&#58;out value="$&#123;formaPamento.key&#125;"/>"><c&#58;out value="$&#123;formaPamento.value&#125;"/></option>
           </c&#58;if>
       </c&#58;forEach>

      Comment

      Working...
      X