On Java Development

All things related to Java development, from the perspective of a caveman.

Archive for March, 2014

Properly Displaying Messages Using an Error Message Dialog

without comments

Introduction

This post illustrates the use of the error message dialog that is contained in baseproject. It is designed to be displayed when exceptions occur during processing.
Read the rest of this entry »

Written by admin

March 31st, 2014 at 4:57 am

Design Patterns

without comments

Java developers should be familiar with design patterns. They provide proven solutions to common problems and incorporating them into your Java designs will result in more reliable and scalable applications.

Read the rest of this entry »

Written by admin

March 30th, 2014 at 5:03 pm

Registering a JDBC driver may disable iSeries user profile

without comments

Back in September of 2004 a colleague was developing a Swing application and incorporated the DBConnection class into his project. The class was responsible for connection management to the AS/400, err … iSeries machine. With it, a problem arose during the time the user logged into the iSeries database using the JDBC connection. It appeared the process was mysteriously rendering the iSeries user profile as expired. Some circles, including the one we consider ourselves to be in, view that behavior as a problem. It was a real mystery and left us scratching our heads.
Read the rest of this entry »

Written by admin

March 30th, 2014 at 4:42 pm

The Immutable String and Performance

without comments

Introduction

Objects of the String class are immutable. If you examine the JDK documentation for the String class, you’ll see that every method in the class that appears to modify a String actually creates and returns a brand new String object containing the modification. The original String is left untouched and memory is used to contain each string object. Over time and across multiple applications, these unused objects will come under the purview of the JVM’s garbage collection cycle which can impact performance of the application server.
Read the rest of this entry »

Written by admin

March 28th, 2014 at 7:19 am

Posted in Java Strings

Iterating through a Hashmap

without comments

Introduction

Unlike Lists, and ArrayLists should come to mind, Maps don’t have an iterator() method like that provided by the Set or List classes. However, you can iterate through the keys or the key-value elements.

There are a few different types of maps such as HashMap, TreeMap and LinkedHashMap. The ordering of the elements in each differ a bit depending on the type of map.
Read the rest of this entry »

Written by admin

March 28th, 2014 at 6:24 am

Using the RichFaces Calendar

without comments

Introduction

The calendar component ensures error free entry of dates in a predictable way. This post presents two examples of using the RichFaces calendar component with its dedicated managed bean, included in baseproject.
Read the rest of this entry »

Written by admin

March 27th, 2014 at 10:51 am

JSF 2.0 Page Navigation

without comments

Introduction

This post shows how to perform page navigation using JSF 2.0 and above, which is much easier than it was using earlier versions.
Read the rest of this entry »

Written by admin

March 26th, 2014 at 9:56 am

Displaying Date or Time

without comments

Introduction

Dates and Times on the iSeries are often stored as integers where the date will be in “yyyymmdd” format and the time will be in “hhmmss” format. This post shows how to properly format dates so that it appears on the web-page as “yyyy-dd-mm” and times as “hh:mm:ss”. For example, a date stored as “20120102” in the database needs to appear as “2012-01-02” when displayed on a web-page. A time stored as “210815” needs to appear as “21:08:15”. The post also presents information on managed beans, how they are referenced by a RichFaces DataTable and the RichFaces DataTable iterative process.
Read the rest of this entry »

Written by admin

March 10th, 2014 at 10:43 am

Using Java Reflection to call methods of a Java Class

without comments

Introduction

This post shows how to use Java Reflection to call getter methods of a Spring context bean (a POJO). The POJO contains the application’s property values and the values need to be logged to the application’s log-file during the application’s startup phase. Since the property name/value pairs differ across projects this means the bean’s method names for each property are also different since their names reflect the names of the properties. Traditional approaches to logging the property values means writing customized code to explicitly call each method by name. Adding to this, whenever a new property is added, the logic has to be modified to include a call to the new method.
Read the rest of this entry »

Written by admin

March 7th, 2014 at 6:03 am