• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

printing JTable from JApplet

 
Siddharth Mehrotra
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , Iam printing JTable from JApplet, iam able to get the printing functionality, but the printed output does not show the grids of JTable.\
can anyone tell me what am i missing .
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The web browser doesn't know how to render anything inside the applet "box" for printing. Java applets, BTW, are forbidden by sandbox rules from printing unless signed, but that's mostly thinking of having the applet submit a print job, rather than as part of another (HTML page) print job. I think that you can do what you're thinking of, but it's not going to be easy or pleasant.
Most often, it's easier (and somewhat better) to have the applet submit its data back to the server and have the server create an HTML page of the table. This will allow somewhat better control over data presentation, since the size, scale, and resolutions of the printer and the display screen are so different that a straight "screen print" is usually disappointing.
HTML has its own problems, of course. You have only approximate control over what comes out. If precise control over fonts, positioning, and paging is needed, you'd want the server to generate a PDF instead.
 
Siddharth Mehrotra
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
What you ave suggeted is definatley an option that was not in my mind, Nut i dont think my clients will like the addition of another Page, for printing, they were are against the principle of having many htmls, or jsps as there might be security loopholes, however tight we code for security, hence we have everything in applet. I just finished writing code for printing and print preview through applet, all works fine , but there are no grids. although the client has not come back with request for grids , but iam sure he will.. so is there any other way to get around this trap.
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your clients are seeing false security. In order to get an applet to print directly, it has to be given additional security rights, which then have to be maintained as the server system changes over time and as client systems (browsers) change over time. An extra JSP is no security exposure at all compared to a signed applet.
A nice feature about modern J2EE servers is that you can set up security rules in the web.xml file that will be administered at an application level. I frequently take advantage of that fact by placing all my administration JSPs and URIs in an "admin" sublevel that is role-limited to people who've signed on using an administrative account.
Java does some nice magic for you. Session info is automatically maintained for the applet as long as you use the standard mechanisms, so you don't have to do any special coding for that. Simply maintain user-specific session info in (or relative to) the user Session object and use the standard Java security mechanisms to guard sensitive data.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic