]]>http://www.catchexceptions.com/java/find-interchanged-words-string-using-java/feed/0Creating PDF document dynamically from HTML using iText in JAVAhttp://www.catchexceptions.com/java/creating-pdf-document-dynamically-html-using-itext/
http://www.catchexceptions.com/java/creating-pdf-document-dynamically-html-using-itext/#commentsMon, 25 Sep 2017 10:34:31 +0000http://www.catchexceptions.com/?p=384To create PDF dynamically we need header, footer ,left and right of a document (can work with any one or one or combinations of any of them)

We are using iText library to create PDF from html content dynamically.

We are taking all these images as user input. We could also take margin of left and right from the user if required.

We could calculate the coordinates i.e x and y of all images dynamically or we could hard code these values.

HeaderFooterPageEvent is the event class which is called for every new page. We are adding header,footer,left and right image in this class only. We can write conditions here if we want header,footer,left and right image on different pages.

]]>http://www.catchexceptions.com/java/convert-word-file-docx-to-pdf-file-using-apache-poi/feed/2Isomorphic maven plugin : How to setup and use in eclipsehttp://www.catchexceptions.com/eclipse/isomorphic-maven-plugin-how-to-setup-and-use-in-eclipse/
http://www.catchexceptions.com/eclipse/isomorphic-maven-plugin-how-to-setup-and-use-in-eclipse/#commentsFri, 01 Sep 2017 08:37:01 +0000http://www.catchexceptions.com/?p=373If you are using SmartGWT, chances are high that you might be using it as a maven project to some stable and popular framework such as Spring.

There are many approaches to download and install SmartGWT jars from Isomorphic repository:

1) you could use command line to utilize maven isomorphic plugin and download, unpack and install SmartGWT dependencies. You might be using something as follows:

But, every time you wish to upgrade or downgrade SmartGWT dependency by changing builDate and/or buildNumber and/or even license. You would have to navigate to your project’s root directory and execute above command.

2) Second and configurable approach is to include maven isomorphic plugin in your pom and use your IDE (say eclipse) to manage SmartGWT dependencies. In this post, I would describe this very approach and I hope, it will make your life a bit easy:

NOTE: isomorphic plugin comes with a lot of dependencies included in its package. You might face some errors in your build after adding this. In such case look for Dependency hierarchy of your maven project to find out any conflicts and resolve them by excluding them from isomorphic dependency. I faced this issue with 2 dependencies and resolved it as follows:

a) go to Run –> Run Configurations and create a new Maven Configuration.
b) Select your project in Base Directory section.
c) Enter isc:install in Goals section.
d) Apply and Run the newly created configuration.

Step 4: Your SmartGwt jars will be downloaded, unpacked and installed in your local maven repository.

That’s it. You are good to go. Feel free to ask me, if you face any issue while following this guide.

]]>http://www.catchexceptions.com/eclipse/isomorphic-maven-plugin-how-to-setup-and-use-in-eclipse/feed/4Integer constant pool in JAVAhttp://www.catchexceptions.com/java/integer-constant-pool-in-java/
http://www.catchexceptions.com/java/integer-constant-pool-in-java/#respondWed, 30 Aug 2017 17:17:37 +0000http://www.catchexceptions.com/?p=370Java caches the integer objects in the range -128 to 127. So, when you try to assign a value in this range to a wrapper object, the boxing operation will invoke Integer.valueOf method and in turn it will assign a reference to the object already in the pool.

On the other hand, if you assign a value outside this range to a wrapper reference type, Integer.valueOf will create a new Integer object for that value. And hence, comparing the reference for Integer objects having value outside this range will give you false

]]>http://www.catchexceptions.com/java/integer-constant-pool-in-java/feed/0Restrict back and refresh button in browserhttp://www.catchexceptions.com/html/restrict-back-and-refresh-button-in-browser/
http://www.catchexceptions.com/html/restrict-back-and-refresh-button-in-browser/#respondSun, 27 Aug 2017 10:34:49 +0000http://www.catchexceptions.com/?p=367The script, which actually restricts the user from getting back to the first page from second page, will exists in the first page itself.

window.history.forward()

The above JavaScript function in the first page uses the history of the browser and forces it to navigate forward instead of going to the previous page. Therefore, every time the user clicks the back button or hits the backspace key, it will result in the Browser navigating or pushing the user forward and showing the same page (the page 2).

The function which executes when we refresh the page is below which restricts the refresh: