Solved

jsp and htnl table Design

Posted on 2004-08-18
12
1,287 Views
Last Modified: 2013-12-03
I am currently writing a web application using jsp. The aim of the system is to price
items of work. I wont go too indepth as to what it does but I have jsp pages that
produce a sumary of prices and descriptions of each item of work(from database)
in html table format. As a requirement I need to be able to print this information from
Internet Explorer. I have been stuck on this for quite some time and i need some expert advise
as to how i would organise the dynamic content of my jsps to produce html tables that can be printed.
Eg.. if there are 400 items of works to be printed this will take perhaps 20 A4 printed pages, each row in the html table may be of different height, depending on the information regarding that item.
Is it possible that each page will contain the table heading;;
(simplified example..)
<TH>Quantity</TH><TH>Price</TH><TH>Description</TH>
also is it possible to avoid table row entries being split horizontaly over 2 pages.
Thanks in Advance..
0
Comment
Question by:adriankelly
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 11832039
if you want to split like this, I think it's possible by using programming.

1                     8
2                     9
3                     10
4                     11
5                     12
6                     13
7                     14

if you want to do like this, it's very quite difficult becuase we will not know how much row will fit to one page
but if you really want to do this you may provide textbox in the prior page for who want to print can configure
how many rows per page.

1                     4
2                     5
3                     6

7                     10
8                     11
9                     12

13
14


Hope this can generate your idea.



0
 

Author Comment

by:adriankelly
ID: 11832165
The table will look like

quanty |  price  | description| tax    |.....Top of table
------------------------------------------------------------------
2         |12.0    | a product  |  12% |    .....Typical table row
-----------------------------------------------------------------------
3         |11.0    | a product   |14% |   ...... A row with increased height
           |          |that needs  |
           |          | alot more   |
           |          |description  |  
------------------------------------------------------------------------
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 11832263
the height of each row will depend on data its reside. but you have fix the width of column by

<table>
<tr>
  <td width="30">
  </td>
  <td width="50">
  </td>
</tr>
</table>

The above code will fix width of first column to 30 pixel and the second 50 pixel
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 11832287
about the table header that you want to print in every page. like I said you may ask client user to submit the number of row to print per page. so we can print the header again when the row reach the value they submit.
0
 

Author Comment

by:adriankelly
ID: 11832479
Imagine you have a web page with a html table with 400 rows in it. Each row is of varying tickness/ height. I need to print this table so that each printed page will have the table heading on it and no rows of the table will be split across 2 of the printed A4 paper pages
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 11832881
Umm. I see. So in case of the last row on that page, if that whole row can fit into the page so how can we push that row to the next page and also re-print the header of the table, right?

this comment just clarify your question. I will try to find solution for you

Regards,
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 3

Expert Comment

by:haobaba1
ID: 11833183
I think you may want a CSS printing style sheet. I am not familiar with the details of how to do it but I think it may be the solution to your problem.
0
 

Author Comment

by:adriankelly
ID: 11839156
Sompol has got what im trying to do.
Iv tried some CSS stuff but havent had much success. I am reasonably new to web design and felt that this problem would have been encountered before.
There has to be a way around it!
Could I take the info from my java classes and show the information on some
type of scrollable  applet as opposed to html??
I really need to get it sorted.  
0
 
LVL 1

Expert Comment

by:TomBruser
ID: 11846284
This would be a different direction for you, but if the report needs to be printed, you should consider PDF generation.  PDF by design was made for this type of a thing whereas HTML by design was not.  There are plenty of free and/or inexpensive libraries to use for generating PDFs.  If you can find one that can provide you with some kind of feedback as to how much space you have left on a particular page as you are generating it, then you've found waht you need.
0
 
LVL 2

Accepted Solution

by:
jjerome00 earned 125 total points
ID: 11853396
HTML wasn't designed to have these features, but you can certainly cheat to get the results you want.  I would take a look at the data you are trying to display, and see how often these multiple lines of description usually are.  

First I would find out how many physical table rows fit on a page.  By physical rows I mean an actual line of text (i.e. one item might produce more than one physical row - your example above has 9 rows).

I would then keep track of how many of these physical rows have been used on the page.  Since you can set the width of the columns, you can calculate how many letters constitute a new row.  For example, the description field in your example might have 100 characters, and you know you can fit 20 characters per row - you have 5 rows for that one item.  The idea is to keep a relatively good idea of how many rows you are displaying.

When you get to the maximum number of rows for the page, then you can close out the table, add some space to get to the next page, and restart a new table.

Of course you will have to play around with your settings a bit, but you should be able to build a few functions to break down the problem into smaller tasks.  You can calculate how many rows an item entry should take and see if it will fit on the page, or if it should start on the next page.

Good luck!




0
 
LVL 1

Expert Comment

by:TomBruser
ID: 11853476
If you decide by chance to look at the PDF route, there is a product called pd4ml.  It is fairly inexpensive (approx $75 US per site or program you use it in) and even free if what you're doing is non-profit.  It converts HTML output to PDF, so if you can manage to get your HTML to format just the way you want you only have to worry about how it fits in one environment instead of making it work for every browser on the planet and every printer configuration that they have.
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 11866647
If you want to use reporting tools for free, I recommend jasper.

http://jasperreports.sourceforge.net/

best luck,
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now