Yesterday, I had a nifty idea. What if I created components out of jsp's? If I needed a textarea, then I would include a textarea.jsp. Now, before you start thinking, wow that is really dumb, there were about 5 other things that had to go with the textarea, or text , or select, or hidden form component, so it seemed like I was simplifying work. I came to the conclusion that I needed Nested-EL tags to do the trick. Unfortunately, no one has written Struts Nested-EL taglib. So, after a brief "conversation" on the struts-dev mailing list, I started writing classes.
After the second cut and paste I decided, there has to be a better way, and remembered that IDEA does file templates. So, I started reading up on how the templates worked and how to make variables. What do you know... IDEA uses Velocity for its templating engine. So, I started reading about how to use Velocity. After about 30 minutes I had two nice templates and I started kicking out 2-3 classes a minute. Pretty good since it was taking me 10-15 minutes per class the usual way. I finished up last night, and integrated this morning. It worked like a champ!
I ended up ditching the idea for a couple of reasons. It was taking forever to compile the jsps, there is a nasty bug in Struts Nested (all versions earlier than Oct 4) that doesn't let you do multiple includes and use nested:root, and I was afraid that the includes wouldn't be performant/scalable.
However, I think Velocity is pretty cool and I will definitely experiment with the idea of replacing JSP's with Velocity in the near future. Struts in Action has a small chapter about using Velocity with Struts, so I will check that out the next time I can catch my breath.
Anyway, I just wanted to give a thumbs up to my friends Struts and IDEA and one for my new friend Velocity. They really helped me out of a jam. I will finish up my Nested-EL tags. Hopefully someone will find it useful.
Posted by carl at October 16, 2003 01:36 AM
Comments