How to create dynamic drag and drop templates? - java

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.

Related

How to manipulate a Check box in Word with Java and save as PDF?

I need to edit some Check-Boxes in a big Wordfile (docx) and save this then as PDF. This file contains many images and is about 19MB big.
Maybe there will be the need of adding some Checkbox and text.
My idea was to use docx4j, but before to learn the ropes I want to ask if this is possible and which is the best way.
May it be better to save the document as a PDF and then use this as base for processing?
Yes, you can manipulate checkboxes using docx4j.
Be aware that there are several different kinds of checkboxes:
legacy checkbox
content control checkbox
checkbox character
and the details depend on which type are present.
For more, you should post a snippet of the relevant OpenXML (and as they say here on SO, code showing what you've tried).
Is it necessary to use only docx4j?
Recently i tried a solution that helps me manage a Word document with checkboxes and save it as a PDF file. I used Plumsail Documents. The case is about how to populate a Word template using a form with checkboxes. You can connect your app via Zapier or Power Automate to activate checkboxes depending on value from your app. You can set the resulting file as a PDF and deliver it by email and across any system using Zapier and Power Automate.
The great is that Plumsail Documents has a templating engine that allows it to operate pictures.
Your case may be like this:
Create a form in Plumsail Form. It will allow you to activate checkboxes depending on your needs, or your users' needs.
Create a process in Plumsail Documents, upload your Word document and set it as a template. Just put placeholders where you want to change or fill a document with some values or data. Set the resulting document in PDF format.
Set the delivery method. Save across apps or deliver by email.
I recommend you to read the article. That solution is not free, but there is a free 30-day trial, so you will have enough time to try it.

wicket DropDownChoice jump to certain selection

I am using wicket DropDownChoice and my list is very long, is there a way that when i click the drop down list and then click on a character the list will jump to the first select that start with the same character
I know this is not the exact solution to your problem, but it will solve your functional issue. If you have very long select list, I would recommend loading it progressively with a search field via Ajax.
wicket-select2 is such a (wonderful) wicket component, integrating the select2 library into wicket to provide Ajax filtering, custom rendering, etc. Although the current integration doesn't offer a way to simply add the select2 behaviour to a static non ajax DropDownChoice, it's relatively easy to do by using wicket-select2's classes as a base. For the wicket-select2 integration all you'll need is to use Select2Choice (or Select2MultiChoice for multiple selects) to which you pass a simple TextChoiceProvider
After you start using such a component, you don't really want to go back to plain old selects, in particular if you have long lists of choices.
Note : using 1.5.8 (and previously 1.4.x), the old selects in my application display the behaviour you are looking for, e.g. standard html behaviour. However from what I understood you don't use a <select> tag in your markup for your DropDownChoice: what are you using then (it's likely this is the cause of your issue).

GWT : Generate THEAD in TABLE

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).

Generating HTML report for JTable data

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).

How to create templates from html page automatically?

I have a use case in which I need to render an unformatted text in the format of a given web page programmatically in Java. i.e. The text should automatically be formatted like the web page with styles, paragraphs, bullet points etc.
As I see first I will have to analyze the piece of unformatted text to find out the candidates for paragraphs, bullet points, headings etc. I intend to use Lucene analyzers/tokenizers for this task. Are there any alternatives?
The second problem is to convert the formatted web page into some kind of template (e.g. velocity template) with place holders for various entities like titles, bullet points etc.
Is there any text analysis/templating library in Java that can help me do this? Preferably open source.
Are there any other suggestions for doing this sort of task in a better way in Java?
Thanks for your help.
There are a lot of hard parts to what you're doing.
The user input
If you don't ask your user to provide any context, you're never going to guess the structure of the text. At least, you should ask them to provide a title, and a series of paragraph in your GUI.
Ideally, you could ask them to follow a well-know markup language (Markdown, Textile, etc...) and use the open source parser to extract the structure.
The external page
If any page is used, the only things you can rely on are the "structural markup". So assuming you know the title of the page should be "Hello World", and there is a "h1" element somewhere in the page, you can maybe assume that this is where the header could go.
But if the pages is a div tag-soup, and only CSS is used to differentiate the rendering of the header as opposed to the bulk of the text, you're going to have to guess how the styling is done : that's plain impossible if you don't know how the page is made.
I don't think Lucene would help fo this (as far as I know Lucene is made to create an index of the words used in a bulk of text ; I don't think it can help you guessing which part of the text is meant to be a title, a subtitle, etc...)
Generating templates from external page
Assuming you have "guessed" right, you could generate the content by
copy pasting the page
replacing the parts to change with tags of your template language of choice
storing the template somewhere the templating system can access it
configure your template / view system (viewResolver for velocity) to use the right template for the rigth person
That would of course pose terrible legal questions, since your templates would incorporate works by the original website author (most probably copyrighted material)
A more realistic solution
I would suggest you constrain your problem to :
using input that has some structure information available (use a GUI to enter it, use a markup language, whatever)
using templates that you provide, know the structure of (and can reuse very easily)
Note that none of those points are related to the template system.
Otherwise, I'm afraid you're heading to an unreasonnable amount of work...

Categories

Resources