A couple of weeks ago I asked this forum on how to implement scripted Actions in order to speed up development. I received a couple of ideas which I tried to implement. Unfortunately none of these ideas meet my requirements. Below is a kind of a small analysis.
Requirement: Instead of writing (compiling and deploying) Action classes, I'd like to use scripts based on Jython, Groovy, etc.. Problems: How to define the Action using xwork.xml? According to the DTD, attribut "class" must be a class which implements at least the Action interface. It can not be a script. The first solution that comes in mind is to define a class may be com.eds.webwork.action.ScriptedAction and use param-tag to reference the script to be executed. <action name="editProdukt" class="com.eds.webwork.action.ScriptedAction"> <param name="script" type="myScript.gy" /> ... </action> What is the problem with that? BSF (bean scripting framework) is "standard" for executing scripts and supports multiple scripting languages. Unfortunately the BSF API supports only calling a script. You can not define and read variable used by the script. You can not call methods. It is like a command line and you start a program. I implemented a simple ScriptedAction class extending ActionSupport and calling a script while executing the execute() method. That was easy. But it does not work. Depending on the Interfaces your Action class needs to support, you'll have to wirte more than one ScriptedAction class. One for each combination of Interfaces. And think about the number of parameters you have to forward to the script. Sounds like this is not the ideal solution. Because of some issues with BSF (might be my limited knowledge of bsf, xwork/webwork as well), I tried using Groovy. Besides the script API, Groovy also supports a reflection like api which allows to create Objects, call methods, access and define variables etc.. Using the Groovy reflection like API was fairly straight forward. But I have still the same problem. I need several ScriptedAction classes. So far I have not found a feasable solution. What might be a solution (not implemented yet). The features Groovy provides (load a class, call methods, implement and extend interfaces, etc.) are very much like, though not identical, to Java and Javas reflection api. Which made me think about using different "actionLoaders". Maybe something like <action name="editProdukt" actionloader="com.eds.webwork.classloader.ScriptClassLoader" classname="myScript.gy" > ... </action> Default would be the java's "default" functionality and ScriptedClassLoader might be used for Groovy classes. Depending on the loader used, the class attribute will have a different meaning. Issues with this approach: The script language must be very very similar to Java suppporting objects and interfaces and must be able to extend native Java classes. From what I've read, Groovy would be a candidate. The script language meta api must support reflection like interfaces to create object, call methods introspection etc. Xwork must support multiple loaders which not only load the objects but which invokes the differents reflection like APIs as well. Kind of a factory. That sound like its not a small change. Sounds to me that using scripted Action with WebWork is not as easy to implement as I originally thought. May be I missed something. I'd happy to discuss may experience in order to find a solution. Or am I the only one believing that scripted action will make development easier and faster and still have the option of using Java actions if performance or any other constraints require it? regards Juergen ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork