× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Cell contents from a table
  • From: "David Duerr" <dduerr@xxxxxxxxxxxxxxxxx>
  • Date: Mon, 14 Aug 2000 17:13:18 -0400

Hello Tom,

You probably want to look  at JSP technology, if you haven't already.  If
you got servlets working,  JSPs will be a breeze to understand.  It will
make what I am about to suggest much much easier.

I would recommend creating the source for the HTML table within a java
utility method, similar to the following example:

public String createHTMLTableSource(HttpSession session, ResultSet rs)
throws SQLException
{
 StringBuffer htmlSource = new StringBuffer();
 Vector v = new Vector();
 int row = 0;
 htmlSource.append("<table>\n");
 while (rs.next())
 {
  htmlSource.append("<tr>");
  BigDecimal code = rs.getBigDecimal("CODE", 0);
  String description = rs.getString("DESCRIPTION");
  htmlSource.append("<td onclick=\"select(" + row + ",0) >" +
code.toString() + "</td>\n");
  htmlSource.append("<td onclick=\"select(" + row + ",1) >" + description +
"</td>\n");
  htmlSource.append("</tr>");
  v.addElement(new Object[] {code, description});
  row++;
 }
 htmlSource.append("</table>\n");
 session.putValue("Vector", v);
 return htmlSource.toString();
}

However, I would create a method that could read any result set and return
the appropriate HTML table source.   One possible solution to knowing which
item was clicked is to store a vector of arrays (as in the example), or a
vector of vectors, or a multi-dimentional array, etc, containing your values
in the http session object on the server side.  (You could store the result
set object for that matter.)   Your javascript function ('select' in the
example) would have to put the selected row and column in some object
(hidden field, javabean) so that it could be retrieved on the server side
when the form is submitted.

Thanks,
Dave Duerr

----- Original Message -----
From: <tmalin@hannasteel.com>
To: <JAVA400-L@midrange.com>
Sent: Monday, August 14, 2000 2:44 PM
Subject: RE: Cell contents from a table


>
> The HTML table I am creating from a servlet contains data from a
resultset.
> The data is dynamic and I have no idea what will be in the first column
> cells for part number. I also have a sort feature, so depending on how
they
> sort the result set, I do not know which part number will be in the first
> column of cells. I am wondering if there is a way to extract data from a
> cell via coordinates cell 1 row 2. Thanks in advance
>
> Tom
>
>
>
>
> +---
> | This is the JAVA/400 Mailing List!
> | To submit a new message, send your mail to JAVA400-L@midrange.com.
> | To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to
JAVA400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner: joe@zappie.net
> +---
>


+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.