2012/10/12 JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>:
> 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?

Yeah, expression in fieldName isn't supported, please register an
issue for that.

You can use alternative syntax as specified here [1]:

<s:fielderror>
         <s:param value="%{'field1'}" />
</s:fielderror>

[1] http://struts.apache.org/2.x/docs/fielderror.html


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to