Dynamic fielderror struts2 validation
i'm dynamically generating fields (from a hashmap):
<s:iterator value="app.fields" status="field">
<s:set name="findex" value="%{'app.fields[' + #field.index + '].id'}"/>
<s:fielderror value="%{#findex}"/>
<s:textfield name="%{#findex}" />
</s:iterator>
This method sets up the textfield ok:
<input type="text" id="saveapp_app_fields_1__id" value="[DE]Enter an ID" name="app.fields[1].id">
but not the fielderror.
I add the fielderrors manually in the validate method. but all field errors get displayed n times f开发者_如何学运维or each fielderror tag. wich implies that what is actually happening is that the #findex
seems to evaluate to null and i'm adding n <fielderror/>
tags.
I could extract the field errors manulally in the jsp but was hoping for a more elegant solution.
Thanks in advance. Michael.
I've never seen a fielderror declared in that way. Perhaps try:
<s:fielderror>
<s:param value="%{#findex}" />
</s:fielderror>
精彩评论