tags:

views:

137

answers:

1

My situation:

On my jsp site I show a table. When somebody click a row, this row must be marked with an other backround color for example. Also more then one row can be marked. Two things are important. First: I bear in mind which rows are marked. Secend: In which order.

My idea is:

I have a ArrayList and put all row IDs in this. So I solve both problems. Now I put this ArrayList in the session for the next click and the row ID ( req.getSession().setAttribute(req.getParameter("rowID") , ""+arrayList.size()); ) for the jsp file.

My problem in jsp file:

I don't now what's called session variable name.

if this rowId alrady clicked? ..

I have got only the bean name. How can I get the content from the session, if exact this line must be marked?

Normally I set a session variable so: req.getSession.setAttribut("printView", Boolean.TRUE) and get a session variable so:

I work with struts, formbeans and jsp.

Sorry, I haven't good English and this problem is so difficult for me. So I can't declare it better at this time.

A: 

What about storing the ids of the rows clicked on a JavaScript Map, there you can change its backgound color. Then, to submit this data to the action, just use struts + ajax (see Struts2InAction book chapter 8).

Also, if your are already uploading the data on the session context, implement SessionAware in your acction in order to be able to access session values.

Hope this help.

Mg
What happens if the user has JavaScript disabled?
daub815
Then this solution will not work. I didn't consider that when I post the answer.
Mg

related questions