Saturday, October 14, 2006

movie list for the buff

primal fear (Edward Norton) Deewanngee in Hindi(Ajay Devgan)
Fight Club (Ed Norton and Brad Pitt)
Snatch (Brad Pitt)
Lock stock and 2 smoking barrels(Jason Statham)
Transporter(Jason Statham)
Trainspotting
Sideways - All about wines
My cousin vinny - Marisa Tomei, Joe Pesci
Coolrunnings
Reservoir Dogs

Saturday, September 02, 2006

struts is good

After a while I am back on a Java project. I hate the technology that I work with as it is the worst of the Java world.. it has EJB, struts and Java 1.3(yeah 1.3 we are still in 1999).
But the clean way of doing server side validation in struts has amazed me.
It has such straightforward and clean implementation(with very hard to find documentation). So I thought I should write a small example.

There are a few simple things to do and you are all set

Your form bean should extend ValidatorActionForm.
The form should implement the validate method


public ActionErrors validate(){}

for anything that you want to return a validation error
your code can look like


if(myName==null)
    errors.add("myName", "My Name cannot be null");
return errors

On your jsp you should have a tag to display these errors
<html:error property=\"myName\">
wherever you want to display this particular error message.

If you want to display the error message at the top of the page or display all the error messages regardless of their location
will do the trick

alternatively you can use the applicationResources.properties file to parse the error messages for you To do that add the following in your applicationResources.properties

error.myName = <img src="error.jpg" /><b>MyName is required</b>

and when you add the error do the following

errors.add("myName", "error.myName");

Custom and generic error messages can also be created and displayed.

Struts is so simple.. Boo to all those who hate struts...:P

Reading Now:
The short history of nearly everything - Bill Bryson
The world is flat - Thomas L Friedman
Angels and Daemons - Dan Brown

Recently learnt :
Streamlined for Rails from Jake Scruggs at TW (http://streamlined.relevancellc.com/) - Crud is Simple