I have a iterator which goes through a list and create their name and for each of them a button. I want when the user click the button put the same name that has been clicked in the session
This is my code
<s:iterator value="packageCities" status="portStatus">
<tr>
<td>
<s:property value="cityName" />
</td>
</tr>
<s:if test="%{status == 0}">
<tr>
<td>
<s:submit method="open" align="center" value="" cssStyle="background: transparent url(image/open.png) no-repeat center top; border: 0px; width: 150px; height: 30px;" >
<s:set name="button" value="cityName" scope="session"/>
</s:submit>
</td>
</tr>
</s:if>
</s:iterator>
But The problem is it only sets the last property , And it doesn’t set it when user clicked the button! so it like when its creating the button it is putting the cityName in the session! But I only want to put different thing in session by clicking different buttons!
Can Any Body Help?
There are two solutions:
As Dave mentioned when the jsp is loaded the values are already set you cannot change them from client side.
EDIT
Ok, as you requested, here is a basic idea of the first method. The idea is to set the id of submit buttons with the respective
cityNameand then onclick of button call a javascript function to set a hidden field’s value with the clicked button’s id (i.e. itscityName)Javascript
Now you can capture the value of the variable
value_to_submitin your action class and set the session variable there.