Embracing the Messiness in Search of Epic Solutions

Month: December 2013

  • IntelliJ: Preventing Wildcard Imports

    PROBLEM I have been getting the following PMD warning that I can’t seem to suppress with PMD’s @SuppressWarnings The reason I’m getting this warning is because IntelliJ will automatically replace all single imports from the same package with a wildcard ‘*’ when the class count hits a certain limit. By using wildcard imports, it also… Read More…

  • Modernizr: Detecting Touch Devices vs Non Touch Devices

    Modernizr has a great feature that allows us to detect whether the browser is running on a touch device (iPad, smartphones, etc) or on a non-touch device (laptop, computer, etc). Even though most modern touch devices support “proximity” hovering (navigating without touching the device screen), the browsing experience still suffer when dealing with onmouseover and… Read More…

  • Java: Invoking Secured Web Service with JSESSIONID

    PROBLEM I wrote a JSP custom tag that invokes a secured web service within the same application to perform some evaluation. This custom tag is only used in the secured views where the user has successfully authenticated against Spring Security, and they have access to these views. The secured web service is also guarded by… Read More…

  • Java: Performing 2-Key Lookup using HashBasedTable

    PROBLEM HashMap is great to perform a simple lookup, for example:- However, what if we need 2 keys to lookup a value? For example, we need “key1” + “key2” in order to lookup “mike”. SOLUTION 1: Create combo key You can combine the keys to create a unique key:- Assuming if the keys are just… Read More…

  • Jadira Usertype: Under JDK 6 it may not be possible to handle DST transitions correctly

    PROBLEM When saving a Hibernate entity that contains Joda Time object, Jadira UserType throws the following warning:- This warning occurs when using this version:- SOLUTION Upgrade Jadira Usertype to the latest version, and the problem goes away:- Read More…

  • Hibernate + Joda Time: Auto Registering Type

    OVERVIEW Jadira Usertype is required when using Joda Time with Hibernate 4. The Joda Time objects are annotated accordingly in the Hibernate entity, and they looks something like this:- PROBLEM This solution works, but it is rather tedious because I can never remember the actual @Type to write, thus I always end up copying and… Read More…