2009 - Pointless 5h1T!

January 21st, 2009

1. 2009 - International Year of Astronomy - who dreams this crap up? worse - who pays someone for this?

2. 20 big-salary jobs, no degree required - Great! Now every high-school drop out wants to be the supervisor for his/her first job. Note that 14 of the 20 jobs are supervisor, manager, or lead in nature. Job #5, Web Surfer with salary of $70,604/year... yeah right!

3. Thanks for the bailout and the buyout - I think I'll redecorate my office - This guy should be fined two times 1.2 million for pulling this stunt. I'm sure it would have been cheaper if he had just wall papered his office with $1 bills.

Using Seam’s AbstractFilter

April 2nd, 2008

Background - I needed to figure out how to stream binary Excel content in a Seam application. This typically is the kind of problem that calls for either a custom servlet or servlet-filter as part of the solution. The solution I came up with involves using the Seam AbstractFilter. Here are some links to the documentation and my Seam-users forum question.
Section 25.1.4.8. Adding custom filters and my post on the Seam Framework forum.

@Name("StreamExcelFilter")
@Scope(ScopeType.APPLICATION)
@Filter(within="org.jboss.seam.web.ajax4jsfFilter")
public class StreamExcelFilter extends AbstractFilter {

public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain)
throws IOException, ServletException {

servletResponse.setContentType("application/vnd.ms-excel");

// generate some excel content and stream it out via the response

}

public String getUrlPattern() {
return "*.xls";
}
}

Hibernate / JPA / EntityManager / Annotations Manager - Cheat Sheet

March 31st, 2008

If you develop applications using Seam + JPA (a.k.a. EJB 3.0 persistence), there is a high likelihood that you are using Hibernate as your JPA implementation. As you develop your persistent entities, your queries, cached collections, etc. you'll need to hunt through the available documentation (javadocs, ref. manuals, online forums, misc. blogs, etc.) in the course of developing the parts of your application that interact with persistence. I'm creating this page as an attempt to collect answers to some of my more common questions; t he kinds of things that should be a on a cheat sheet.

Query Hints

Part of the Query interface (javax.persistence.Query). Example:

Query query = entityManager.createQuery("from User u").setHint("org.hibernate.readOnly", true);

Syntax: Query setHint(String hintName, Object value)

Hint Description
org.hibernate.timeout Query timeout in seconds ( eg. new Integer(10) )
org.hibernate.fetchSize Number of rows fetched by the JDBC driver per roundtrip ( eg. new Integer(50) )
org.hibernate.comment Add a comment to the SQL query, useful for the DBA ( e.g. new String("fetch all orders in 1 statement") )
org.hibernate.cacheable Whether or not a query is cacheable ( eg. new Boolean(true) ), defaults to false
org.hibernate.cacheMode Override the cache mode for this query ( eg. CacheMode.REFRESH )
org.hibernate.cacheRegion Cache region of this query ( eg. new String("regionName") )
org.hibernate.readOnly Entities retrieved by this query will be loaded in a read-only mode where Hibernate will never dirty-check them or make changes persistent ( eg. new Boolean(true) ), default to false
org.hibernate.flushMode Flush mode used for this query
org.hibernate.cacheMode Cache mode used for this query

Controlling Form Submission - Mixing JSF and Javascript

March 29th, 2008

I get tired of forgetting this stuff and rediscovering it.

Technique #1: Form tag onsubmit handler

This technique is based on setting a value for the HTML-form tag's onsubmit attribute.
<form onsubmit="return YOUR_HANDLER">
YOUR_HANDLER is typically a Javascript-function call that returns true or false. When the form is submitted, via a submit-button click, this handler is invoked. If you programmatically submit the form, by invoking form.submit(), then this handler is not called. Here is what happens based on the return value of YOUR_HANDLER:

  • YOUR_HANDLER returns anything other than false - the form gets submitted normally.
  • YOUR_HANDLER returns false - the form is not submitted.
  • <form onsubmit="return preSubmitCheck(param);">
    ...
    </form>

Respek!

December 28th, 2007

Welcome to Tekmology.org. The domain (and name) of this site is inspired by the character Ali G who refers to technology as tekmology. Most of my posts on this blog will be about my adventures in working with tekmology. In some cases, I'll just rant and rave about an annoying aspect of some piece of tekmology I'm trying to use to do my work. Sometimes, I may actually post a solution to a problem that occurs when ``tekmology goes horribly wrong'' ;-).