A subtle note that might improve over-all readability (albeit subjective)
of the scripting embedded in this useful example jsp:
<%
if (i == default) {
out.print("checked");
}
%>
can be expressed as
<%= ((i == default) ? "checked" : "") %>
And the line
<%
out.println(hashtable1.get(hashtable2.get(hashtable2.get(vector.elementAt(i).toString
))))); %>
can instead be expressed as
<%=
hashtable1.get(hashtable2.get(hashtable2.get(vector.elementAt(i).toString
()))) %>
I'm not trying to suggest one way is necessarily better than the other, but
both accomplish the task and we've found over-all using <%= %> blocks
instead of more complex java code blocks result in more readable jsp's once
they start getting big.
Randy Beiter
Flashline.com
Boxwell Daniel
<daniel.l.boxwell To: [EMAIL PROTECTED]
@AC.COM> cc:
Sent by: A Subject: Re: How to generate complex
tables using JSP and useProperty
mailing list
about Java Server
Pages
specification and
reference
<JSP-INTEREST@jav
a.sun.com>
09/13/99 09:22 PM
Please respond to
daniel.l.boxwell
Rupesh,
I am working on something like this right now . I haven't implemented
sorting,
but the other things you've asked for aren't too hard. Here is a snippet:
<table name=<%=i%> width=675 border=1 cellspacing=0 cellpadding=0>
<!--Begin JSP Generated Dynamic Rows -->
<%
for (int i = 0; i < vector.size(); i++) { // Display 1 row for each record
%>
<tr>
<td width=60 align=center>
<input type="radio" name="radioDefault" value="<%=i%>"
onClick="setDefault(value)"<%
if (i == default)) {
out.print("checked");
} %> >
</td>
<td width=175 align=center>
<% out.println(hashtable1.get(hashtable2.get(hashtable2.get
(vector.elementAt(i).toString())))); %>
</td>
<td width=175 align=center>
<% out.println(hashtable1.get(hashtable2.get
(vector.elementAt(i).toString()))); %>
</td>
<td width=175 align=center>
<% out.println(hashtable1.get(vector.elementAt(i).toString
()));
%>
</td>
<td width=60 align=center>
<input type=checkbox name="ChkDelete<%=i%>" value="<%=i%>"
onClick=setDelete(<%=i%>)>
</td>
</tr>
<% } %>
<!--End JSP Generated Dynamic Rows -->
</table>
Basically, you can just open up a for loop in JSP, temporarily close it,
print
out all the HTML you want, then open JSP again to close the for loop off.
You'll
see here that I periodically pop back into JSP to fill in some of my table
cells.
I hope this helps you out.
Regards,
Dan Boxwell
Rupesh Choubey <[EMAIL PROTECTED]>
09/14/99 12:54 AM GMT
Please respond to Rupesh Choubey <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Daniel L. Boxwell)
Subject: How to generate complex tables using JSP and useProperty
What would be the (best) way to implement a complex table using JSPs. By a
complex table, I mean one where :
* one of the columns is a button
* one of the columns is a checkbox
* different columns have different display properties (different text
fonts, sizes, etc.)
* rows have different properties - e.g. alternate rows have different
colors, rows might have different colors based on values in columns,
* SORTING needs to be done by clicking column headers
THESE and other similar requirements make the entire JSP task a bit of a
challenge.......
Does anyone have ideas / code / lessons learned ??? Appreciate all help.
This is a big hurdle we are trying to overcome and help would be greatly
appreciated.....
Thank you,
Rupesh.
(See attached file: att1.htm)
What would be the (best) way to implement a complex table using
JSPs. By a complex table, I mean one where :
- one of the columns is a button
- one of the columns is a checkbox
- different columns have different display properties (different text fonts, sizes, etc.)
- rows have different properties - e.g. alternate rows have different colors, rows might have different colors based on values in columns,
- SORTING needs to be done by clicking column headers
THESE and other similar requirements make the entire JSP task
a bit of a challenge.......
Does anyone have ideas / code / lessons learned ??? Appreciate
all help. This is a big hurdle we are trying to overcome and help would be
greatly appreciated.....
Thank you,
Rupesh.
