VERSIONARY::BLOG
Andre Mermegas extends Weblog

SEE MY RESUME!




Recent Entries
Imagine if Apple..
This blizzard is crazy.
Finished the StoreFront WebWork Port
WebWork StoreFront App
re: WebWork: aaargh!
I'm Amiga OS =)
Finally easy win xp services
How do you like your Actions?
Godspeed, Columbia STS-107
Looking for more Webwork insight


Monthly Entries
February 2003
January 2003


Links n' Stuff

Wil Wheaton
IntelliJ Tech Net
Oracle Tech Net
Javaranch Forums
The Serverside

 


February 03, 2003

How do you like your Actions?

So, I've been doing research on struts and webwork. I started with struts because there seemed like there was more info on it, read the manning book, enjoyed it thoroughly now have delved into webwork. I must say that I like them both, though at this point if I had to choose, I'd probably go with webwork just because it seems a little more open ended and cleaner to use.

Along the way during my education, I came across two different Action models. Struts uses the Action/ActionForm mindset for separating data from Action and thats it. Which seemed like a good thing to me at first, I thought well why should the parameter data be tied into the action that uses it, its a good separation. Its kind of ugly seeing all that getter/setter in an Action that supposed to do logic.

Webwork allows you to do it 2 ways,but most of their examples tie data into the Action, theyre mindset being that the Action is basicly just a Javabean with an execute method, give or take for simplicitys sake. They also allow you to separate the data using a javabean via the Beanutils class and reflection which yields a result similiar to Struts' Action model.

So the more I think about it the more I wonder, which is the best way. Does anybody have any compelling arguments as to which they prefer? Or maybe they mix it up, depending upon the use of the data. I'm open to suggestion at this point but one situation which comes to mind that points to separation is the following:

If I wanted to have my Action take a bunch of user info from a form for later use during the session, and I had my data tied directly into the Action how would you go about putting that data in a beanlike way onto the session?

As per my current understanding, you'd have to populate a bean first,if you do that you may as well have started out with the separation,and toss the bean into the session, that was already populated. Unless there was some way to reference a previous Action's data on the property stack? like:


<ww:property value="MyAction/name"/>

where name is property on MyAction or something.

Posted by Andre Mermegas at February 3, 2003 09:31 PM | TrackBack
Comments

This "session" saving stuff you're talking about is actually supported by WebWork. It's all done automatically. Never used it myself, but ping the mailing list. Jason Carriera is the one who wrote it originally. It might not even be in CVS right now, but I'm sure it's pretty trivial and could be added or you could write your own ActionFactoryProxy yourself that does this.

Posted by: Pat Lightbody on February 3, 2003 10:43 PM

I love how Patrick says I did it and then says it's trivial :-)


Seriously, it was pretty trivial. It's not in CVS because I didn't want to slap another feature into WW 1.3 while we're trying to release it.


One thing I noticed while doing our Struts comparison is that the form bean separation in Struts is a red herring. In your action, you'll have to do a



MyActionFormType myAction = (MyActionFormType) form;

which is just tying your form bean implementation 1-1 with your action! At least in Webwork, if you wanted to, you could have a subproperty named myBean and name your form field vars myBean/prop1 and have them populated automatically without having to do this mapping. Webwork is just a lot more flexible in these respects, giving you lots of choices.

Posted by: Jason Carreira on February 3, 2003 11:36 PM

Note that recent versions of Struts support DynaBeans, which are an attempt to get away from the 1:1 mapping of Forms to actions, which I always found extraordinarily tedious myself.

Posted by: Joseph Ottinger on February 4, 2003 01:53 AM

Then again, you could look at Maverick (http://mav.sf.net/). It allows you to use any of the mentioned approaches. Look for different controllers in http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mav/maverick/src/java/org/infohazard/maverick/ctl/.

- FormBeanUser.java = The struts' way
- ThrowawayBean2.java = WebWork's way
- ThrowawayFormBeanUser.java = Hybrid approach

And if you ask me what implementation is the most clean, I would definitely say Maverick's. And Maverick is also truly open for any kind of view techonologies (WebWork is mostly JSP and Taglibs, so is Struts, althought there is some support for Velocity in both).

Posted by: bungle on February 4, 2003 02:45 AM
Post a comment



















February 2003
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28