tags:

views:

289

answers:

1

I have the following code:

<c:forEach items="${mergeList}" var="sublist" varStatus="index">
                <c:forEach items="${sublist}" var="item" varStatus="row">

So my intention is to display each 'item' in a list. When the user does click over a row, open a floating window with the full item description. I set the variables with the request scope so I can get them in the other form,

<c:set var="merge0" value="${sublist[0]}" scope="request" />
<c:set var="merge1" value="${sublist[1]}" scope="request" />
<c:set var="merge2" value="${sublist[2]}" scope="request" />

But the problem comes when I set the variables in every iteration so when the floating is opened it always appears the last elements of the list, of course is overwriting every time. I know what's the problem but not how to solve it.

Any suggestion?

+1  A: 

If the "floating window" concerns a brand new HTTP request, then you really need to pass them or its identifier as request parameter(s). E.g.

window.open('popup.jsp?itemid=${item.id}');

This way the popup.jsp can access them by ${param.itemid}. Or if there's a servlet in between listening on doGet() you can of course access them by HttpServletRequest#getParameter().

If the "floating window" is sort of initially hidden fixed div which you show up using JavaScript, then just write the values out as if it are JS variables, so that you can access them in JS context. E.g.

<script>
    var itemid = ${item.id};
</script>

Or write them as plaintext or hidden input element(s) of the form in the fixed div.

<input type="hidden" name="itemid" value="${item.id}">

Which the best way is depends on the actual functional requirement which wasn't made very clear in your topicstart.

Hope this helps.

BalusC