How to print current ClassLoader with or without Spring

Now we explain how to print a class loader associated to current thread. We can use Spring, and with one row of code, we solve the problem! We use the ClassLoaderUtils class.

For example:

System.out.println(
org.springframework.util.ClassLoaderUtils
   
.showClassLoaderHierarchy(
Thread.currentThread().getContextClassLoader()));

If we don’t want to have any library dependency Read the rest of this entry »

How to running explorer 6.0 and 7.0 in the same pc

For web designer and web developer must havo to running and testing the web page in all the most populars browsers.
The most populars browsers are Internet Explorer and Firefox (then Safari for Mac users). But for the Microsoft browser, there are a lot of differences between version 6 and 7.
Then is indispensable to have installed both versions.

Ufficially is not possible. But ther is a program, a Virtual Machine, that can do this!

The first step is Read the rest of this entry »

Using dozer context mapping as factory bean

If you have a DTO (Data transfer object) or a VO (Value Object) and you want to mapping them
to a specific Pojo depending of a value of an attribute, you must to implement with a multiple if/else if
condition or instance of.

For example we have CarRaceVO with type attribute. If type have “F1″ value we instantiate
an F1Pojo, if type == “Nascar”, a NascarPojo etc.

We don’t want to write pieces of code like this: Read the rest of this entry »

How to create a custom converter for copy properties

Now we would to introduce a short tutorial on how to create a custom converter for type String for the Common Beanutils Framework version 1.8.

If we would to copy the value of the propertry of an object, but for the Strings, we want to initialize to empty String the property when the original bean have the property setted to null.

In the first step we create a custom String converter class Read the rest of this entry »

How to configure a composite foreign key in Hibernate (Tools) 3.0

The scenario of this tutorial is: we have a table with a foreign key, that reference to a composite primary key of another table. Probably a Legacy database scenario… These constraints are only logical defined. Suppose we have 2 tables. USERS and ORDERS with a one-to-many relationship. But USERS has a composite primary key: zipCode and birthDate.

Is not possible to generate the many-to-one in the HBM.XML with Hibernate Tools, because Read the rest of this entry »

How to build a breadcrumb with Spring Webflow 1.0.4

In this tutorial we explain how to create a simple breadcrumb with the new Spring Webflow framework, arrived at 1.0.4 version, released the 26 June 2007.

The first step is creating a class that implements FlowExecutionListener, a WebFlow framework library:

public class BreadcrumbListener implements FlowExecutionListener { }

Then, you can override one of the next two methods defined in the superclass (from the WebFlow API docs):

void requestProcessed(RequestContext context)
Called when a client request has completed processing.

void requestSubmitted(RequestContext context)
Called when any client request is submitted to manipulate this flow execution.

For our requirements, the best choise is the Read the rest of this entry »