user2003910
user2003910

Reputation: 43

get the value from map using struts tags by passing another property as key

<s:property value="currentStep" />
<s:set var="nextURL" value="%{campaignStepsMap.get(currentStep).nextUrl}" scope="page" />
<s:property value="nextURL" />

Here currentStep is a property having Integer value comming from action class. and campaignStepMap is a linkedHashMap. I want to get the value exactly similar in java with following code

campaignStepsMap.get(currentStep).nextUrl();

but here in Jsp page i'm not getting value corresponding to the index. Seems value="%{campaignStepsMap.get(currentStep).nextUrl}" is not reading currentStep as integer. What should i do?

Upvotes: 2

Views: 2621

Answers (1)

Aleksandr M
Aleksandr M

Reputation: 24406

You can get value from map like that:

<s:property value="campaignStepsMap[currentStep].nextUrl"/>

And if you want to use <s:set> tag with scope="page" then you need to use #attr to get the value.

<s:set var="nextURL" value="campaignStepsMap[currentStep].nextUrl" scope="page"/>
<s:property value="#attr.nextURL"/>

Upvotes: 1

Related Questions