The Daily Bugs

A web developer's daily life

September 28, 2013

Handling Java Generic Types with Reflection

When declaring a class or an interface as being parameterizable, or when a subclass extends that parameterizable class, we come into cases where we need to access the information of those generic parameters, this is where Java Reflection comes in handy.
This tutorial will introduce ReflectionUtil, a utility class that uses java.lang.reflect standard library. It provides easy access to the standard reflect methods that are needed usually when dealing with generic object types (java.reflect.Type).

Read More

July 10, 2013

Date Range Validation with PrimeFaces Calendar

PrimeFaces <p:calendar> has some good attributes like mindate and maxdate, considering we have two calendars “start” and “end”, to validate a proper date range between them, we can set the mindate of “end” calendar to the value of “start” calendar. This will do a good job, but not a complete one, still when you edit it manually, you can pass through, and the range will be false.
To achieve that, we’re going to implement a custom JSF 2 date validator.

Read More

April 19, 2013

Caching and reusing an evaluated EL expression in JSF

Sometimes you run into a scenario where you have an evaluated EL expression property, that is used widely through your JSF page. Evaluating the value each time is a waste of performance.
JSTL core <c:set> helps you caching the value into a scoped variable, that can be accessed later on through the scope it’s defined on.

Read More

April 18, 2013

Clickable PrimeFaces Wizard Tabs

PrimeFaces wizard component <p:wizard> is awesome, but recently in my work I was asked to get the tabs clickable, which are not by default in version 3.5.
This is a full tutorial explaining how you can achieve this.

Read More

August 29, 2011

Java Localization with PropertyResourceBundle

A tutorial about PropertyResourceBundle object and .properties files; how to create them, load their values, use them in business logic code, or JSF view page.
This tutorial will try to gather all the uses in one place.

Read More

July 15, 2011

Resizing java.awt.Image with constraining proportions using ImageUtil

With every application I create, I always come into image manipulation, which can be really tricky in Java and sometimes even complicated.
The function that was always needed is to resize an image after the client user uploads it, or reduce its quality.
As you know when ever you feel like a function needed over and over you go and create a utility class for it, so you can use it easily in any new projects.
ImageUtil.java is the class I created. It contains one method (for now) called resizeImage.
I’ll leave you with the full class, read the documentation for class usage and method functionality.

Read More

Older Posts