Tuesday, April 09, 2013

JSF 2.x Tip of the Day: PrimeFaces Chart Coding Exam

PrimeFaces Pie Chart

Background

I have been asked to interview a number of engineers over the last couple of years. We were interested in hiring an engineer with a background in JSF specifically PrimeFaces, Java EE 6, and NetBeans.

Basically I wanted someone...like me.

I came into work one day, and I was told that I needed to interview someone in about an hour about a position. The person claimed experience in all of the aforementioned technologies. I needed to come up with a coding exam idea for them. Tick tock tick tock.

I decided to create a NetBeans project using the sample Java DB database, JPA, EJB facades, and a JSF front end using PrimeFaces with a pie chart. The whole process took about 7 minutes to create. When the engineer arrived, I showed him the result and said "I want to see the same results", and explained that I used the sample database from NetBeans.

The engineer was successful and created something similar in about 30 minutes, and additionally showed me up by adding percentage tags to the chart. We hired him after the interview. I am glad to say he is an integral part of our team today.

Coding Exam

What do I want?

Please create a JSF application using PrimeFaces that displays a pie chart using data provided. The application must be developed using NetBeans and Java EE 6 technologies. The example data is provided using the sample Java DB database in NetBeans  We would like to have a pie chart that shows sales totals by customer as a percentage of all sales. You have 1 hour to complete the code, and will be required to explain your design decisions, and results.

Note: I just showed them the pie chart that was generated in the browser and not the actual code. I don't want to sway the candidates decision making, or give them hints on how to solve the problem.

Here is the code for the project: PrimeFacesCodingExam

Conclusion

Even if you don't use this in a coding exam, it is a good example of combining Java EE technologies using NetBeans  and PrimeFaces.

2 comments :

sroughto said...

This is cool, calculating the sum in Java rather than in the database. Could you do the same thing by executing a query that joins the necessary tables and returns customer name and total sales?

John Yeary said...

Certainly! I just used this technique since it is really fast for me.

Alternatively, it could be done with a query in JPA. I used this to "show the candidate the output I want to see". I leave them to come up with similar, or better results. Then we discuss their work, and I show them my work to have them critique it. Just like you. :-)

It is a win for everyone.

Popular Posts