Announcement Announcement Module
No announcement yet.
Spring bind and xhtml compliance for arrays Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring bind and xhtml compliance for arrays

    This is my first post here, hope It's ok.

    My employer has decided all new pages developed for its website should be xhtml compliant.
    Thankfully W3C society checks html with:

    Alas, spring bind to an array positioned object breaks the xhtml compliance.
    e.g: the following code snippet
    <c:forEach items="${command.accounts}" var="account" varStatus="loopStatus">
    <td >
    <spring:bind path="command.accounts[${loopStatus.index}].accountNumber">
    <input type='text' class="${status.error?"invalid":""} inputText" name='${status.expression}' value='${status.value}' title="${status.errorMessage }" size='14' maxlength='14' id='${status.expression}' tabindex='${12 + loopStatus.index }'/>

    results in this w3c validation message:

    "Below are the results of checking this document for XML well-formedness and validity.
    Line 269 column 142: character "[" is not allowed in the value of attribute "id".

    ...size='14' maxlength='14' id='accounts[0].accountNumber' tabindex='12'/>

    It is possible that you violated the naming convention for this attribute. For example, id and name attributes must begin with a letter, not a digit."

    The status.expression is rendering the id as 'accounts[0].accountNumber' which is seemingly against the xhtml standard.
    Has anyone got a compliant way of working with arrays/lists?

    Much appreciated