Thursday, February 24, 2011

JavaServer Faces: Facelets


I've gone and done it: my first full, raging JEE-oriented tutorial, A Simple JSF Facelets Project, in almost three years. In that time I've chosen not to write formal tutorials for a lot of the sub-JEE technologies I've worked with since I felt that others had more than adequately covered the topics. Others like, and very especially, Lars Vogel.

However, I'm on my own again. Just as years ago I couldn't find a tutorial on JSP and servlets that worked (perhaps rather, I couldn't find any that still worked with the new releases of the Eclipse IDE and Web Tools Platform), I have been unable to find a tutorial on Facelets that works.

I've figured out what others have missed and have no explanation why they left their tutorials in a state of unworkability, but I have a theory. They just don't go back to show how to solve problems they forgot they had or answer questions others new to their topic will have, questions they had to answer for themselves, but moved on without taking notes. Their tutorials, once you've followed them and created a project in Eclipse, simply do not work. You're on your own. And others tell me that they've been unable to get anything to work either.

Well, as I'm fond of saying, I'm not the brightest Crayola® in the box. So, I have to take careful notes because often I find myself smack back in the same state of perplexity at why my Tomcat server won't start or why some JSF construct won't render. And if I don't know, there must be someone else who doesn't.

Recently, I exchanged mail with some guy from India who admitted to me that he had tried playing with JSF earlier last year, but just couldn't get things to work. His problem was the same as mine: libraries. The chaos in JSF/Facelet approaches needing JSTL, then no longer needing it in Faces 2.0, etc., libraries coming and going, what version of what library works with what version or versions of other libraries, etc. It's unconscionable. And without the seemingly innate intelligence of these tutorial and book authors who publish then run off to their next thing, I'm obliged to feel my way forward via trial and error, a process I loathe.

And that old, long-winded tutorial I wrote on JSP, servlets and setting up Eclipse? I still get e-mail out of the blue at least once per month thanking me for it. It's still relevant even though it's become mildly embarrassing after journeying so far down the Eclipse and JEE road. I need to rewrite it, to make it more relevant and fix the rather embarrassing admissions of perplexity in my explanations. Now that I know.

Today's tutorial also builds on two other, full-length articles I've written on exposing the recent research I've done on setting up a solid set of libraries to use for JSF, plus additional libraries for Facelets work.

And I show how to internationalize and localize the simple application.

Today's tutorial doesn't go as far as I'd like. I need to wax more forthcoming on aspects that need explaining. That requires much more effort and guesswork. There are also some navigational problems that would be more obvious if the little application did much more than it does. That's very important to fix.

But, I'm moving ahead with the next tutorial. It will be a demonstration of Facelet templating; I just haven't chosen what I'm going to show yet.

Down the road I have plans to integrate Spring web flow. It's a mountain of work I've set for myself.

Friday, February 11, 2011

How does it feel to view the world...

...from the dominating summit of eighty-one years?

Happy birthday to my father:

Center of attention!


Very young World War II veteran


Old sea dog and world-traveler


Connoisseur of weird and vintage autos
(and a certain redhead)


Perennial geek


Pater familiae


...and all-around great guy!

Saturday, February 5, 2011

Butterflied shrimp

Today we saw the most magnificent shrimp at Costco and couldn't resist picking up 6 of them which, at $13 per pound, ran us a bit more than $8. (I think the vendor was very generous to us.) Then we went home; I was wondering what I'd actually do with them.

Come evening, I knew I couldn't put it off (I'm very superstitious about storing crustaceans in my refrigerator longer than a few hours). On my way up to the kitchen, I decided to butterfly and fry them. Here's the recipe I came up with.

How many per person? We ate three each; I was at the edge. I couldn't eat any more. If they are not the principal foodstuff of your meal, more than two U-8s (8 shrimp per pound) is more than enough per person.

    ½-2 lbs large gauge shrimp (U-8s are perfect, but a bit smaller is fine)

    2 cups water
    2 eggs
    ¾ cup corn starch

    — panko bread crumbs
    — unsweetened, finely grated coconut (optional)

    5 cups frying oil or ghee (or at least 2" deep)

I didn't use coconut: it gets old real fast for me. Julene loves it, though. If you want to use it, mix it thoroughly with the panko crumbs before dredging.

Preparation
Perform mise en place of all ingredients: The batter will separate fairly quickly so it's better that everything be ready at once: oil heated to 350°, shrimp deveined and butterflied, crumbs ready for dredging, batter to hand.

Tip: You can heat the oil while processing the shrimp. I think it's okay to do the first round of battering and dredging even if it's done before the oil is hot.

1. Butterfly shrimp by deveining, removing all shell but the tail. Using a small, but very sharp knife, slash not quite all the way through to open the shrimp up and lay it out flat. Beat it flat with a tool just as you would a breast of chicken, but take great care not to destroy it (it takes a far lighter hand than meat, but it's the same action).

2. In a blender, mix water, eggs and cornstarch until totally homogeneous. Pour into a bowl.

3. Dip shrimp in batter and let drip a couple of seconds to eliminate excess then dredge immediately, piling crumbs on top and pressing down to seat as many as possible. Set aside on a plate. Process all shrimp.

Ensure that oil is hot enough for cooking.

Ready to cook
4. Re-batter shrimp and re-dredge one at a time. As each one is ready, slide it immediately into the oil to cook, count to 20, then remove to drain on a paper towel. This should be enough for them to reach a nice, golden brown color.

Do not over-cook or they will be rubbery. Do not attempt to cook under temperature or you will have to over-cook them to reach golden brown. Ensure that the oil has returned to temperature before repeating step 4 for the next shrimp (or however many you're cooking at once if you're real clever).

It's nice having a tiny sieve to skim the fallen panko between shrimp. I didn't, so halfway through cooking I strained the oil with a large sieve into another pan, then returned the oil to my first pan (only 6 shrimp—so, yeah, it gets pretty messy).

Oh, yes, they were delicious except for the one I over-cooked because my oil had gone cold cooking the previous one. (You don't think I hatched this recipe without mishap and hard knocks, do you?)

Friday, February 4, 2011

Maven of Maven?

Hmmmmm... no, at least not for now. However, we've made some important strides in groking Maven as used in Eclipse development this week. Long used "as is, as already in place," Maven will henceforth be a tool clutched firmly in our own fist.

http://www.javahotchocolate.com/tutorials/maven.html

Tuesday, February 1, 2011

Won't get fooled again!

Tunis falls and a new government is installed.

As I watch Egyptians struggle to throw off their oppressive government in turn, and I see an opposition leader hasten to profit from the situation by assuring the people that he's ready to champion their cause, I can't help but think of what for me was the greatest hit The Who ever had. I don't think I need to say more; the sense and drama of this song doesn't need me to belabor it. It's a story as old as government itself:

Meet the new boss—same as the old boss!

Bet your sweet bippy.

On an obliquely related subject, ...

I naturally went to the web to find a suitable performance of this song and picked the link below. I was doubly rewarded not only a fine performance and the memory of what it's like to be so young and supple (look at what Peter Townshend can do while playing his Les Paul), but I also found this comment below the video. Priceless.

Me: Man, the Rolling Stones are awesome!!!
Friend: The who?
Me: Them too.

http://www.youtube.com/watch?v=Rp6-wG5LLqE