Wednesday, September 05, 2007

Invalid Property Binding Feedback

Matt Raible blogged today about why Struts 2 sucks. At the same time he concluded that Stripes sucks as well. Why? Because neither framework handle invalid property binding feedback properly. Well, let's discuss what might be proper and let's talk about Stripes because I love Stripes. I want Stripes to be the best it can be and we can find ways to improve it, let's do that.

Stripes doesn't use OGNL. When Tim designed Stripes he used OGNL in the beginning and later found out that he could write something a bit smaller and faster that was specific for Stripes and remove another dependency from the project. I think that is great. One less JAR I need to fetch.

One of the many nice things about Stripes (specifically over Struts) is the ability to create pages without wiring up the actions on the back end. with Struts (this could be different in Struts 2, someone please correct me) you had to have your form beans, validation, XML all correct and complete before you could even view your JSP. With Stripes, if a binding resource is missing it's ignored. Is this a flaw? I don't believe so.

When you submit the form or when the page requires binding, which typically isn't on view, Stripes will tell you what you've missed. It's in the debug log, not on screen. So if you had a form that required a first name and a last name. In your action bean you have two strings, firstName and lastName. On the JSP you fat finger lastName to lkastName, the form will display just fine. This is what I would want. I want to see my form. When I submit the form, this is what I get in the debug:

DEBUG Could not bind property with name [lkastName] to bean of type: FormTestActionBean : Bean class com.app.web.action.FormTestActionBean does not contain a property called 'lkastName'. As a result the following expression could not be evaluated: lkastName

And now I know what I need to fix. I'm not 100% sure that Matt views this as a flaw or if maybe he doesn't understand that Stripes does this. From his post I am led to believe that Matt wants immediate feedback if there are binding issues, even prior to submitting the form. I don't agree that this should be an issue. What do you think?

6 comments:

Matt Raible said...

A warning is good enough IMO. I have my log4j root level set to WARN, so I didn't see any messages from Stripes. A debug level message seems flawed, as does info. I think changing it to "warn" would be a good idea. Furthermore, it'd be even better to have a development mode and deployment mode like Struts 2 and Wicket have. In development mode, you might get stack traces on your page, in prod mode, you get logs, but no adjustments to the UI.

Also, Struts 2 is a lot like Stripes when you add in its Zero Configuration and Code Behind Plugins. You can code Actions and JSPs and never touch any XML. I do think Stripes is a cleaner, better documented implementation though - it just lacks the strong community and marketing.

Maybe Stripes and Struts 2 should merge?

Gregg Bolinger said...

I'll raise a JIRA about changing it to WARN. You make a good point there. Stripes has a very elegent exception handling mechanism and so my stack traces will typically show up on the page in my own development mode. I guess we could argue over if that is really the frameworks responsibility.

As far as Struts 2 and Stripes merging...in general I'd be against it. Theoretically I wonder what Struts would bring to Stripes other than a huge community? I haven't looked at Struts 2. Maybe that will give me something to do this weekend.

Thanks for the comments Matt.

anand said...

greg, I posted some additional thoughts here.

http://scattered-tidbits.blogspot.com/2007/09/stripes-struts-and-property-binding.html

I completely stand behind the stripes philosophy of making it simple.

anand

Gregg Bolinger said...

Thanks anand.

Daniel Cruz said...

I like this blog is fantastic, is really good written. Congratulation. Do you want to see something more? Read it...: Costa Rica is a country with a extremely sense of freedom. The landscapes are for much the most green in whole center america.The chances of investement are way to high, the average of Americans, European and people of the entire planet who is buying here is up in the sky !!!
Great investment opportunity in Costa Rica: condos, costa rica real estate, costa rica property. Visit us for more info at: http://www.jaco-bay.com/

Anonymous said...

The Guild Wars 2 Gold had been pretty much separate from google search as well as expression. Yahoo had just 4 beyond Fifty final results confirm (8%), Live messenger experienced Several of fifty (6%), and also Yahoo! Visit Here acquired not one. The term most abundant in legitimate final results has been 'Paris Hilton' that arrived Three of the 7 appropriate internet pages. Currently Guild Wars 2 FB aware that this isn't a completely inclusive review, nonetheless it at the very least signifies that legitimate web coding will not are much of a issue to the leading lookups on the top search engines.