struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>
Subject Tag fielderror with ognl expressions on fieldName
Date Fri, 12 Oct 2012 04:28:31 GMT
Hi,
  I'm using Struts2.2.3. I have a iterator that creates textfields with the
same name, which I receive at the server as an array of Strings

     <s:iterator value="myQuestionsInfo" var="myQuestions"
status="iterStatus">
        <s:textfield theme="simple" cssClass="dijitTextBox"  name="answer"
value="%{answer[#iterStatus.index]}" tabindex="15" autocomplete="off"/>
      </s:iterator>

I can user OGNL to fill the fields with the submitted values if there is an
error on the validations. But I'm not able to show a fielderror for the
specific field that failed. I want to add the error in the action as
follows:
addFieldError("answer[1]","value is invalid")

and in the JSP
     <s:iterator value="myQuestionsInfo" var="myQuestions"
status="iterStatus">
        <s:textfield theme="simple" cssClass="dijitTextBox"  name="answer"
value="%{answer[#iterStatus.index]}" tabindex="15" autocomplete="off"/>
        <span class="red"><strong><s:fielderror
fieldName="%{'answer'+#iterStatus.index}" theme="simple"/></strong></span>
      </s:iterator>

So the fieldError tag will pickup the field error "answer[1]" and show that
fieldError. But it does not work, nothing appears. It is possible that the
attribute fieldName does not support OGNL expressions?

Thanks

JL

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message