PSquad's Corner


PSquad's Corner

 ::home::  ...stuff... ::java::  ::school::  ::technology::  ::misc:: 


Sunday, September 15, 2002

Now that WebWork has a GenericDispatcher, we need to allow a much more extensible configuration. In order to do this, I belive that views.properties needs to be removed completely. For example there is a big difference between:

Foo.success=Bar.action (the Bar action)
Foo.success=Bar.action (the URI "Bar.action")

Clearly we've moved past the point where results are just JSP views, so we need to be able to specify this information in our config files. Not only that, but in order to allow for customized Actions (such as a PoolingAction) we will need properties for various actions. These properties are actually sort of already in WebWork, in the form of the CommandAware interface. Basically by specifying your action as:

Foo.action=Foo!someCommand

You are really doing this:

<action name="Foo" class="Foo">
 <property name="command">someCommand</property>
</action>

Essentially, the concept of "aliases" in the configuration should be done away with and replaced with generic properties. So besides commands, we can no start customizing the behavior of all our actions based upon the property value. Then for views, you can use a pluggable ViewFactory like so:

<action name="Foo" class="Foo">
 <property name="command">someCommand</property>
 <views>
  <view name="input" factory="webwork.view.JSPViewFactory">
   <property name="jspName">input.jsp</property>
  </view>
  <view name="error" factory="webwork.view.JSPViewFactory">
   <property name="jspName">/global/error.jsp</property>
   <property name="fullPath">true</property>
  </view>
  <view name="success" factory="webwork.view.ActionViewFactory">
   <property name="actionName">Bar</property>
   <property name="copyPrevious">true</property>
  </view>
 </views>
</action>

Any thoughts?


4:02:04 PM    comment []

OK, I spent an hour tonight hacking out the feature in WebWork I've been waiting desperately for: Action chaining to happen on it's own via a central dispatcher that all other dispatchers utilize. Here's the code to execute an action (including the entire chain) using this new core dispatcher. From this point on, ActionFactory shouldn't be used directly to execute Actions in your java code. Instead you should do the follow:

GenericDispatcher gd = new GenericDispatcher();
gd.prepareContext();
ActionContext.setParameters(...);
ActionResult ar = gd.executeAction(actionName);
Object finalView = ar.getView();
List actions = ar.getActions();

Now the actions List has all the actions in the entire chain and the finalView Object will contain the view that the last action in the chain returned (such as "success.jsp"). This was all accomplished by making one small tweak where the ViewMapping classes don't return "Foo.action" (a String) anymore as a view that chains to another action, but now actually return the _Action_ itself, which really just makes a TON more sense. I've added all this to CVS, hopefully I didn't break things too badly. My code (including chains) works well, but I haven't done too much testing. I guess I'll find out from the WebWork guru's if these changes are worthwhile on Monday.


2:07:41 AM    comment []


September 2002
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
29 30          
Aug   Oct




Copyright © 2002 Pat Lightbody