In an application I am experiencing problems with field limitations.
At the moment I am using a multiline edit box control on an xpage to capture the information and I save it in the back-end on the Notes document as a text field e.g:
doc.replaceItemValue("emplInformation", employee.getInfo());
I was not aware that users paste "complete stories" in the field so it breaks my functionality (I am not handling the error so the document will never be stored).
Therefor I was thinking that instead, perhaps I could save the information to a rich text field instead and hereby avoid the field limitation.
Is this a smart thing to do? Or, should I try other options?.
I have to mention that the user is not going to enter formatted text (yet). So I do not have to take notice of that. Nor that they will paste in images or html.
I have never worked with rich text or mime in Java before so I am not experienced in read/write such data. Any code example how to store it to the back-end document is highly appreciated.
If you want to store data in a field, was could be greater as the field limit, you may consider using the OpenNTF Domino API.
You can store in a single field, if to big, the field is automatically converted to a RichText item.
Is used it in our HR Assistant application, for info about to bypass the limit see, http://elstarit.nl/2018/01/18/make-the-nsf-modern-again-with-openntf-domino-api/
Related
I am saving text in other language like Urdu, Punjabi, Spanish etc in DB from HTML form. It gets saved in DB and I am able to display same text in same language via PHP on UI (HTML page). Now I want to do same thing in JAVA. In PHP I am using html_entity_decode(). How can I do same in JAVA.
Thanks in advance for your help. Please let me know if my question is not clear to you.
Here is an example to explain the necessary steps to use Arabic language font in Android app development.You can customize this according to your requirement. Same procedure is applicable to other languages including Persian or urdu.
Follow this link for complete example
Another helpful API would be JAVA Internationalization.Check Its documentation for further help
The usual way to do it with Java is through property files:
one file per language
each file is filled with a list of pairs key/message
the files are managed with an instance of ResourceBundle class
See for ex. Backing a ResourceBundle with Properties Files
About using it in html pages, it depends how you generate them.
UPDATE
About storing data filled by a user in any language.
It is strongly recommended to encode the data with a unique charset, usually UTF-8, all along the way, i.e.:
from the html form where the user enters data
to the html displaying them
through the db used to store them.
For html, the charset must be set up in all the pages.
For db, check what is the default charset used, and if needed changed it (if it's possible!)
If at any step of the process a change of charset is required, then explicit conversion will be needed.
Most of the time, Java deals with encoding without requiring to explicit any charset. But it not always true, like e.g. with copy from String to byte array.
The webpage I'm working on with JSP and a Java Servlet needs to enable the user to write comments and articles which contain text but also Code of various languages (including html and javascript).
The data is stored in a mysql database and displayed later on the page.
For input, I thought to use one of the many WYSIWYG Editors out there.
Those usually produce (x)Html code for the database.
This means I need a type of sanitizing on serverside before inserting into the database since the editor could be easily circumvented and malicious code displayed onto the site (the database itself is secured by prepared statements).
What would be the best and most simple way to approach this topic?
And would it make more sense to switch to BBCode Input instead of html?
I've found several threads here around, but most don't take into account that code actually needs to be displayed on the site and most threads are several years old already.
Huge thanks in advance!
You can use KefirBB to use BBCodes or for HTML filtration.
https://github.com/kefirfromperm/kefirbb
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.
How would you use SafeHtml in combination with links?
Scenario: Our users can enter unformatted text which may contain links, e.g. I like&love http://www.stackoverflow.com. We want to safely render this text in GWT but make the links clickable, e.g. I like&love <a="http://www.stackoverflow.com">stackoverflow.com</a>. Aside rendering the text in the GWT frontend, we also want to send it via email where the links should be clickable as well.
So far, we considered the following options:
Store the complete text as HTML in the backend and let the frontend assume it's correctly encoded (I like&love <a="http://www.stackoverflow.com">stackoverflow.com</a>) -> Introduces XSS vulnerabilities
Store plain text but the links as HTML (I like&love <a="http://www.stackoverflow.com">stackoverflow.com</a>) in the backend and use HtmlSanitizer in the frontend
Store plain text and special encoding for the links (I like&love [stackoverflow.com|http://www.stackoverflow.com]) in the backend and use a custom SafeHtml generator in the frontend
To us, the third option looks the cleanest but it seems to require the most custom code since we can't leverage GWT's SafeHtml infrastructure.
Could anybody share how to best solve the problem? Is there another option that we didn't consider so far?
Why not store the text exactly as it was entered by the user, and perform any special treatment when transforming it for the output (e.g. for sending emails, creating PDFs, ...). This is the most natural approach, and you won't have to undo any special treatment e.g. when you offer the user to edit the string.
As a general rule, I would always perform encoding/escaping/transformation only for the immediate transport/storage/output target. There are very few reasons to deviate from this rule, one of them may be performance, e.g. caching a transformed value in the DB. (In these cases, I think it's best to give the DB field a specific name like 'text_htmltransformed' - this avoids 'overescaping', which can be just as harmful as no escaping.)
Note: Escaping/encoding is no replacement for input validation.
I am working on a project here that ingests internal resumes from people at my company, strips out the skills and relevant content from them and stores it in a database. This was all done using docx4j and Grails. This required the resumes to first be submitted via a template that formatted everything just right so that the ingest tool knew what to look for to strip the data.
The 2nd portion of this, is what if we want to get out a "reduced" resume from the database. In other words, I want to search the uploaded content I now have, and only print out new resumes for people who have Java programming experience lets say. So I can go into my database, find the people who originally had java as a skill, and output a new set of resumes that are also still in a nice templated format, and only have the relevant info in them, instead of ALL the content.
I have been writing some software to do this in Java that will basically use a docx template, overwriting the items in customXML which are bound to the content controls in the doc, so the new data shows up and can eb saved as a new docx with that custom data.
This seems really cumbersome to me, and has some limitations. For one, lets say my template has a place for 3 Skills, and the particular person has 8 skills. There seems to be no good way to add those 5 additional skills to the docx other than painstakingly inserting the data with all of the formatting XML tags and such. This is a real pain, because if the template changes, I dont want to have to go back into my software and edit source code to change that additional data input XML tag to bold instead of italic.
I was doing some reading up on using Infopath to create a form that I could use to get the input, connecting to some sharepoint data source or something to store the stripped out data. However, I can't seem to find out if it is possible using sharepoint to get the data back out, in a nice formatted way. What would the general steps for this be? It seems like I couldnt find very much about this topic with any quick googling.
Thanks
You could set up the skills:
<skills>
<skill>..</skill>
<skill>..</skill>
and use a "repeat" content control pointing to the container. This would handle any number of <skill> entries.