• Post Reply Bookmark Topic Watch Topic
  • New Topic

any ideas?  RSS feed

 
Gemma Cameron
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my problem, if anyone can help it would be greatly appreciated!!!

------------------------------------------------------------------------------

I wish to write a servlet which queries a database (MySQL) and then, according to the status of a task in the DB, a HTML table background will change colour to indicate its progress.

I am not too sure about how to approach this... I am assuming that rs.getString(i) will get the value I require...? (rs being a ResultSet and i being the column to read). I wish to use a series of if statements to set the colour for each cell in the table, as in the following pseudo-code:

if (rs.getString(i) == "In Progress")
{
colour = amber;
}


if (rs.getString(i) == "Complete")
{
colour = green;
}

else
{
colour = red;
}


I have another problem, however I will bother you with that once I have completed the first...

Thanks in advance...

Gemma
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order for the html table to be updated the browser will have to request for an updated page (refresh). I believe javascript might be able to accomplish this. A servlet can't push data to a browser without a request. Maybe an applet would be another solution.
 
Gemma Cameron
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may help if I explain myself better:

The site is required to do a search for a component number, which the user inputs. This then brings up all the corresponding information about this component (i.e. the tasks) in table form, as well as a coloured table to indicate the progress:

--------------------------------------------------
|Analysis|Build|Test|Release|Live Awaiting Closure|
--------------------------------------------------

Depending on each task's status, I want to change the background colour.

I hope this is now clear?

--------------------------------------------------------------------------

My next feat is for the user to select which task they would like to expand and, on the smae page, a table appears with only the analysis or build (for example) task information and comments.
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would just set the color for the row in html as you generate the html. The if statments would work, but I would build a map of the status/color combinations you want to use. Then you could:
"< rd =" + map.get(rs.getString(i)) + "the row" >

I'm not sure on the exact html, but I think that would put you on the right track.
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gemma,

Another point regarding your if statements



will always return false because you are trying to compare objects, not the actual text string. You need to use the equals method to compare the string values, e.g.



also note that the double-quotes around the colour attribute need to be escaped using a back-slash.
[ March 16, 2005: Message edited by: Ben Wood ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!