Friday, March 18, 2011

Baltimore : Charm City

Baltimore is not my desired city to be visited during my Spring break.  Since I did not plan anything ahead of time, I had to settle with Baltimore especially since a friend of mine just recently moved there for job.  So, here I am now in the charm city.  There are only two things I am looking forward to in this city: their renowned crab cake and Aquarium at the Inner Harbor.

My friend lives in the Atrium apartment complex which is near Lexington Market.  After googling online for a good crab cake place, I found out a good one is right near me, in Lexington Market.  But the reviews from Tripadvisor warned people about going to the "shady" Lexington Market.  They went as far as to saying that there's drug dealers etc.  I think it might be true but feeling adventurous and not wanting to miss a good crab cake, I went there.  The place is called Faidley's Seafood and their all lumps crab cake was advertised as an award winning, king of crab cake in the country.   One big crab cake was 12.95$.  It was good but for me, it'll be just once in a lifetime event.  I enjoy good food with cheap price and for me, a good local favorite must be reasonably priced and good.  Faidley's crab cake was good but not good enough for 12.95$.  But now, at least I tried.  Personally I don't think the food here is that cheap.  Compared to New York, it's almost the same price.

Then, I walked to the Inner Harbor's National Aquarium.  I never really liked Baltimore.  I do not know which I don't like more: Philadelphia or Baltimore.   Philadelphia is bigger than Baltimore and had a slightly more diversed population.  Baltimore is much smaller and a majority of people are African American.  Since the beginning of my walk from Lexington Market to Inner Harbor, I encountered 80% of the people who are African American.  

Inner Harbor is always charming and especially on a day like today, it is wonderful. (Today temperature was in 70s!!!) .  I always have a thing for aquariums and zoos.  Therefore, I visited most aquariums in the state: Monterey Bay Aquarium in California, Coney Island Aquarium in NY, Aquarium in Camden NJ and the one in Long Island.  And I thought I never got a chance to step inside Inner Harbor Aquarium.  I was wrong; I had been here before, just that my memory totally eluded the visit.  Anyway, it was a nice way to spend the day amidst the stressful life of mine.  The highlights of the aquarium included the dolphin show(which I paid extra to see) and the feeding of the stingrays and sharks.  One other highlights was Jelly Fish Invasion.  It was a smaller and newer exhibit but jelly fishes are always amazing.  There was also a showcase of one big Pacific Giant Octopus.  They were short-lived (about 3-5 years).  The female octopus will avoid eating anything for 6 months after they laid their eggs.  They lived separately in a cave to protect the eggs.  Therefore, after the eggs hatched, the female octopus will be too weak and they normally die.  A female octopus laid about a million eggs at once but only a few survived to adulthood.

My day concluded with a visit to Filene's basement near the harbor and some mini crab cakes from the Phillip's Seafood.

Sunday, March 13, 2011

How to validate your manual date input of <rich:calendar>

As my boss would always say it, "programmers are lazy".  That sentence has a certain truth to it.  As a programmer, I came to rely on certain framework and their respective built-in components.  But there's no perfection to anything in this world and my latest struggle with JSF Richfaces involve the user of <rich:calender>

<rich:calendar> is a good visual component for date functions.  It allows for both manual and visual input and can specify date format among other features.  It allows automatically data conversion to any date style that you specified.  However, there is a problem to it; if you specify date style to be "MM/dd/yyyy" format and you enter "08/22/88", the date is converted to 08/22/0088.  I believe that is the inherent problem with JSF <f:converDateTime> tag.  

The work around I implemented was I used a date validator.   (I guess you can try to write a custom date converter but it'll be much more complicated and I was not willing to spend more time on this matter as I had other bugs and features to work on.)  Essentially what the date validator does is it will display error message if you enter 08/22/88.  First the calendar component will convert it to 08/22/0088 and it'll be validated against my custom date validator.  Since I do not allow years to be started with anything other than 18, 19 or 20s, the validator will throw an exception.

The use of validator is pretty straight forward.  You will have to declare you validator in your face-config.xml file and then you can call it using <f:validator>  The only thing I think important is that I used Java' Pattern and Regular Expression classes for validation.