Showing posts from December, 2011

Detecting the generic type in runtime

Assuming we have a class:

public abstract class GenericDAOImpl

Now what if we need to get the "Class" object identifying the generic type's class type in run time ?

Class entityClass = (Class)((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];

Kindly share if there are other ways.

Persisting a set of enum values

This was tricky. After you specify your bean's parameter varable:

private Set weekDays;

Annotate it using the following annotations:

@Extensions({ @Extension(vendorName = "datanucleus", key = "cache", value = "false"), @Extension(vendorName = "datanucleus", key = "cache-lazy-loading", value = "false") })
@Persistent(defaultFetchGroup = "true")

The cache related extensions will force your set to be fully loaded when the bean is looked up so it's not null when read after the bean being detached.

Invoke tapestry form validation on the client side

I just read a mail on the users list discussing this matter so I'll post it here with some links as a future reference for me and other searchers on the web.

First this mail enlightened me that one can control his when would tapestry client side validation be invoked by tapestry in the first place. The form component's parameter "clientValidation" can be set to different values from the "ClientValidation" enum.

So the guy asking wanted tapestry to validate his form before the form submits and no when the input fields blurs. Setting the "clientValidation" parameter to "submit" will do just that.

Now to the main point, what if we would like tapestry to ALSO validate a specific field based on another event ?

Event.observe($(' fieldNeedOnBlurValidation '), 'blur', function(event) {

I claim that this applies to tapstry's default javscript framework…