Monday, June 25, 2012

Wanted to generate PDF and MS Excel Reports within Java application?


Do you want to develop a reporting capability within java based application? I have shared my knowledge/experience on reporting projects which I have worked earlier. Happy to hear if from you if you have any concerns/suggestions.

To work with PDF Reports:

We have used FOP and iText earlier (not both in a same project) to create a pdf report using Java. Please read the below for each of its pros and cons.

FOP:
It is an open source Java API to create a PDF report dynamically in a template format. If you have a XML data and formatting object template (xsl), creating PDF report using FOP is very easy.  I would say only 3 lines of code will help you to create a PDF report.

XSLFO is a XSL formatting objects and can be used for formatting XML data and to generate PDF report. Using FOP, it is easy for us to generate a read-only pdf. At the same time, we can’t alter an existing pdf or we can’t apply any security within a pdf using FOP. Want to know more? Have a look @ http://www.codeproject.com/Articles/37663/PDF-Geneartion-using-XSLFO-and-FOP

iText:

It is an open-source and more powerful java api for creating a PDF file using java. Using iText, developers can create a PDF file with digital signature and security (including having permission for opening a document, print/copy the pdf). In addition to that, we can manipulate, split and concatenate the existing PDF(s) within Java program. Also, we can build a form within PDF document. Good set of working examples are available @ http://itextpdf.com/

You can choose the right framework to address your pdf needs.


To work with Excel Reports:

We have used POI and JExcel earlier (not both in a same project) to create a Microsoft   xls (spread sheet) report using Java. Please read the below for each of its pros and cons.

POI:
It is an open source Java API to read/write/modify Excel spread sheets dynamically if you have a template already (xsl). Say implementing the POI will be very easy if you already have the xml data response and xsl template for your report. As I understand, POI is not improved as much like JExcel in terms of protecting the xls spread sheet data. Want to learn more, please look at http://poi.apache.org

JExcel:
It is an open source Java API to read/write/modify Excel spread sheets dynamically. If you want to apply security OR to derive a new data (Sum, average etc) using the existing data, JExcel will be the right option. It is a Java API, we wanted to write Java code for column alignment, font, style etc.  Also, it supports copying charts and images into excel sheet. Want to know more? Visit http://jexcelapi.sourceforge.net/

If you unable to follow the examples used in the above links, any issues or sample codes, reach put to me.

_NjN

Saturday, June 23, 2012

“Lines of Code” Calculator


Are you finding difficulty in calculating “Lines of Codes” written in java based application? I can strongly recommend the open source tool “LOC Calculator” to do the same. It comes with very simple UI screen which is used to calculate the LOC in 10 seconds of time. Sounds interesting? Try the LOC calculator @ http://code.google.com/p/loc-calculator/


Cheers,
_NjN

Friday, June 1, 2012

Password Encryption (Hex Code) using java


In my early blog (http://nanjundanonlinedictonary.co.in/2012/02/password-encryprion-using-java.html), I had articulated the easy way of password encryption using java. The program would result an encrypted text in a hash format but not in a hex code as we can see in Spring ACEGI framework. Here in this article, we are specifically focus on possibilities to convert SHA hash password SHA hex password.

Old Code:
  
byte rawBytes[] = md.digest();
String hashPassword = (new BASE64Encoder()).encode(rawBytes);
  

New Code:

byte rawBytes[] = md.digest();
StringBuffer strBuffer = new StringBuffer();
      for (byte rawByte : rawBytes) {
        strBuffer.append(Integer.toHexString((int) (rawByte & 0xff)));
      }
String hexText = strBuffer.toString();

Saturday, May 19, 2012

How to update the Log4J logger level dynamically for a web application?


Are you looking for an option o update the Log4J logger level dynamically for a web application? If so, here is the solution for people like you to update the logger which doesn’t require any log4j,xml file configuration change or serve restart.

Here we had developed a jsp page that will show the current loggerName, loggerlevel and the list of logger levels lits it can take. Now, you can select the new log level from selectbox to set the new logger on the fly.

Here is the code sample. Wanna try?


<%@ page import="org.apache.log4j.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
Dynamic Log4J control
<%
            Logger logger = Logger.getRootLogger();
            logger.setLevel(Level.toLevel(
                                    request.getParameter("selectedLevel"), Level.INFO));
%>


           

                       

           

           

                       

                       

                       

           

           

                       

                       

                       

           


                       

Dynamic Log4J control


                       
Current Log Level Logger Name Set New Log level
${rootLogger.level} ${rootLogger.name}

Friday, April 13, 2012

Ear comparator


Many Occasions, we might end up with comparing two ear/war files in our project for some reasons. Here is the link for EAR comparator utility (Good stuff Joseph! – The mastermind behind this tool). You may think it will be good if you have some utility to compare such circumstances.

I have link below for ear files comparator utility. I strongly recommend this tool to make your job easier. 


Anymore suggestions? Drop those in comments section.

Cheers,
-NjN

Sunday, April 8, 2012

To start work with Maven (more than a build and deploy tool)


So far I have used ant as a build tool in all my projects. When I recently gone through the articles, found Maven used widely in most of the Java/J2EE applications. I tried to install maven in my machine recently. But found many issues and it was very difficult to follow the setup to complete my very first build.

I have found an excellent material to work with Maven. It has step by step guide with the screen prints. I found the below link is very interesting to follow. Hope this will useful to you as well.


Friday, April 6, 2012

How to work with browser specific Style sheets

If you would have worked with web applications I am sure you might had difficult time to deal with applying the style sheets specific to browser and its’ version.
Have found nice information on applying the browser specific style sheets recently.  Wanted to share with you guys.
Below article explains very well on conditional based approach (browser & version) to apply the different CSS files. This is most commonly used approach as well. 

CSS cross browser selector comes with noticeable approach, where we no need to write different CSS files. Within the same CSS file we can mention the style classes based on the brower&version.

The second will be most preferable if we have css file with lesser contents. What do you think?

Pega Decisioning Consultant - Mission Test Quiz & Answers

The Pega Certified Decisioning Consultant (PCDC) certification is for professionals participating in the design and development of a Pega ...