I need to generate report in HTML for my Swing based application.
Is it possible to convert JTable into HTML code (HTML table)?
If yes, how can I convert JTable into HTML table, or is there any alternative way to generate HTML for reporting?
Ok. I've come to three solutions over night (you can combine them if possible):
The basic - the most control and flexibility - you generate HTML by iterating over rows wrapping data with table, td, tr. For better visual effect you must manually include it in the generated output.
Create a model with JAXB or Jackson annotations (or any library that provides you with easy JSON/XML creation) and save your model to/with a "html template" with fancy stuff like CSS and cool visual effects provided by for example jQuery UI (and extensions: Heatbox, etc.) DataTables, KendoUI, Flexigrid, or even Google Charts. To adapt to particular "visual-effects provider" you probably must manipulate a little your generated XML/JSON data but with JAXB you can even produce strict HTML table snippet.
Data generation like in 2. - but you use this data with external tool/application that can read XML/JSON (or any format that you provided). You can try to use Jasper reports (here and here, iReport, Eclipse BIRT) - the report tools should have option to Save as..->HTML Page.
In case of charts (and if you don't want above JavaScript based solutions) you can also generate images (that you will display in HTML page) with some java library that gives you the possibility to save generated images (for example JFreeChart etc. or Swing's paint components trick).
Related
I am trying to make some existing PDF's into templets.
Because these documents hold real data I am replaceing this data such as names and addrsss and making them into dummy place holders.
Examples
[[Name]]
[[Address1]]
When I alter the text via the iText version 5 library replace via a program I can use the template.
To speed things up I tried to use Adobe DC.
When using this method the template stops working.
Any ideas?
From what I understand of your question;
you have (or want to have) a template document
fill in the template with data from a program
turn this back into a pdf
You can easily achieve some of your goals with iText.
I suggest you look into http://developers.itextpdf.com/examples/form-examples/clone-filling-out-forms
I have a requirement of developing a functionality where user can dynamically define a template (labels, textboxes, labels, rows, columns, parent child relationships among above elements etc). These elements(such as combo boxes) may be bound to different database tables.
For example, the user may define a template T1 for a specific use case U1. But this template is not restricted to U1 only. It may be needed to be used in another use case U2, where it is a sub part of a bigger template.
Once the templates are defined, another user may load the templates (HTML form) and enter data into it. At a later stage, I need to reuse this data and template to generate PDF reports. Since PDF reports may sometimes need to have a different layout than the HTML form, I would need parent child relationships between elements as well.
As of now, we are achieving by generating an XML from a user interface where a user can select elements from a dropdown and specify properties. At run time, these XML are transformed to HTML using XSLT. Another XSLT is used for generating PDFs. The limitation of this scheme is that it is very tedious to incorporate any user requests (such as multiple columns, add tables into forms etc).
I was wondering how other people achieve this and is there an API/Library for doing the same ?
I have looked at HTML5 and JQuery drag and drop features, but it would require me to add everything from scratch (such as dynamically add columns,rows etc.)
The best thing to create dynamic form is using angular js.
It is very good framework for front end development
Here is the working link for
angular js form
Sorry, I only gave example form dynamic forms here are some example for drag and drop
Angular drag and drop 1
Angular drag and drop 2
http://angular-js.in/dragular/
I hope this will help.
There are libraries out there for dealing with databases, such as JDAL,jOOQ and many many others.
For creating forms and reports, however, Oracle does have their Oracle Forms and Reports suite. There are also alternatives, such as OpenXava, that can also do these things (and probably better, I've worked with 10g/11 and it can be a pain sometimes). If you're more interested in using XML and other markup languages, you might like FOXopen.
All of these can output to PDF and other types of documents.
Where I work, we use Oracle Forms and internally written programs to craft our reports.
Is that possible to generate THEAD in a TABLE in GWT ? Do I have to create my own Widget ?
I'm following the Google Tutorial on GWT, https://developers.google.com/web-toolkit/doc/latest/tutorial/gettingstarted... but when see the generated HTML I get sick :o)
So I gess that yes I can use whatever I need to use to be able to generate better HTML.
In fact, I have to report if I can do good HTML/CSS/JS whith this technology. So I try to know what is possible to do with GWT.
Column headers of CellTables will be rendered in a <thead> section.
You can also use HTML with an HTMLPanel (made much easier using UiBinder) if you don't need to manipulate the table's structure dynamically (assuming you're putting widgets in there, otherwise you can very well do whatever you want with it; this is because widgets have a specific lifecycle to avoid memory leaks with event handlers).
I'm fetching data from different RSS / ATOM feeds and sometimes the HTML data I receive contains HTML tags but they dont have close tags or some other issues and it screws up the page layout / styling.
Somethings there is class name / id clash. Is there any way to sanitize it?
If anybody can point me to some reliable Javascript / Java implementation.
You can give JTidy a try.
JTidy can be used as a tool for cleaning up malformed and faulty HTML.
Another option is HTML Cleaner
HTML found on Web is usually dirty, ill-formed and unsuitable for further processing. For any serious consumption of such documents, it is necessary to first clean up the mess and bring the order to tags, attributes and ordinary text. For the given HTML document, HtmlCleaner reorders individual elements and produces well-formed XML. By default, it follows similar rules that the most of web browsers use in order to create Document Object Model. However, user may provide custom tag and rule set for tag filtering and balancing.
I have used NekoHTML with great success. It's just a thin layer over the Apache parser that puts it into error-correcting mode, which is a great architecture as every time Apache gets better so does Neko. And there's no huge amount of extra code.
I'm looking for a good web framework for compositing multiple JSON sources fetched with HTTP requests in to static HTML. I am not looking to do this on the client-side (browser, javascript), I am looking for the best server-side solution.
So, what I need to do is:
Fetch several different JSON documents over HTTP
Format that JSON as HTML content, mostly with templates but some dynamic custom HTML
Basic login/logout/preferences customization, nothing major
Mostly stateless pages; what state there is, comes already in the JSON
User / search engine friendly / bookmarkable URLs; should be customizable accurately
How I'd like to do it:
A lean solution, perhaps just a template engine
HTML templates that have no custom syntax over HTML/XML, like Wicket and almost like Tapestry
Application server that is scalable and utilizes multiple CPUs properly (for example, a single Python process does not)
Preferably Java, but if Java doesn't have anything that fits, willing to consider others
As for the template part, if this were to be in JavaScript in the browser, something like PURE would be my tool of choice.
You might want to check out RESTx. That's an open source platform for the easy creation of RESTful resources. It allows you to write custom data access and integration logic in either Java or Python. Getting data from multiple sources and combining them is what it's made for, so this should be a pretty close fit. Data output is rendered according to what the user requested. For example, a further JSON data source, or the same data rendered in HTML.
The HTML rendering is currently according to a built-in template. However, that should be easy enough to modify. I'm one of the developers on that project, so if you need some special template functionality, let me know and I will see what I can do.
To give you an example: Assume you have two JSON resources, in your code you would write this (I'm giving a Python example here, but the Java example would look very similar):
status, data_1 = accessResource("/resource/some_resource")
status, data_2 = accessResource("/resource/some_other_resource")
# data_1 and data_2 now hold a dictionary, list, etc., depending on the JSON
# that was returned.
# ... some code that combines and processes the data and produces a dict or list
# with the result. The data object you return here is then automatically rendered
# in either HTML or JSON, depending on the client request.
return Result.ok(data)
Also take a look at the example for some simple data integration here.
I think that the only framework you need is a library that reads json. The templates can very well be standard jsp pages.