开发者

Dynamic fielderror struts2 validation

开发者 https://www.devze.com 2023-03-05 03:07 出处:网络
i\'m dynamically generating fields (from a hashmap): <s:iterator value=\"app.fields\" status=\"field\">

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号