Gaurav Gupta
Gaurav Gupta

Reputation: 4691

Runtime value population in Struts 2 textfield

I need to show list of text fields where number of textfields will be equal to number of element in the map and label should be key of the entry and value of textfield should be value corresponding to the key.

I attempted something like this:

<c:forEach var="score" items="${result.examscore}">
    <s:textfield label="%{score.key}" value="%{score.value}"></s:textfield>
</c:forEach>

I checked this code by hardcoding label and value's value. So, iteration is working fine, it is just a matter of populating values in textfields.

Upvotes: 2

Views: 649

Answers (1)

Roman C
Roman C

Reputation: 1

The variable score is not available in the value stack. Try

<s:textfield label="%{#attr.score.key}" value="%{#attr.score.value}"></s:textfield>

Upvotes: 2

Related Questions