문제

I'm looping over a list and want to access the value to create a text input field. Unfortunatley I'm failing to access the loop variable inside the <s:textfield> tag

This is what I tried:

  <s:iterator var="tag" value="searchTagList">
    <s:property value="#tag"/>
    <s:textfield key="searchResults.#tag" name="#tag" value="#tag" />
  </s:iterator>

The <s:property value="#tag"/> is evaluated correctly and shows the loop variable. But the #tag in the <s:textfield> is never evaluated.

I also tried to put <s:property value="#tag"/> instead of #tag without success.

도움이 되었습니까?

해결책

The tag's key attribute used instead of three ones name,value,label. As far as two of them you have already defined, you can change

<s:textfield label="%{getText('searchResults.'+#tag)}" name="%{#tag}" />

The value is retrieved by the name attribute. You should provide a getter for the name evaluated in the name attribute. Note, getText() is available if your action extends ActionSupport. And you have to force name evaluation in the name tag.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top