[Webwork-devel] CommandDriven behavior and enhancement
Brought to you by:
baldree,
rickardoberg
|
From: Hai P. <yf...@ya...> - 2002-04-02 22:29:51
|
Hi,
Currently there are two minor usage problems with
CommandDriven factory. I will summarize them briefly
below. A patch is attached along in this email.
1. Command Name:
Right now the name of the command is fetched from the
value of the submit button:
i.e.: for <input type="submit" name="command"
value="Add"/>, the command would be "Add".
Now that's fine for name in English or in one locale.
However, it won't work if the value is changing
depending on the current locale. I propose to add the
following feature:
If the user specifies:
<input type="submit" name="command{MyCommand}"
value="Add"/>
(note the additional '{MyCommand}')
then ww will use "MyCommand" as the command name
instead of using the value of the submit button.
2. Recursive CommandDriven invocation:
This happens when there is a "command" parameter in
the request's parameter list. This command is supposed
to be used by the action handling the form only. Now,
if within that action, you dynamically execute another
CommandDriven action, or within the view of that
action you use <webwork:action> or #action (velocity),
ww will set and invoke the same command. This is not
an expected behavior. Of course you can use
MyAction!myCommand to get around that, but right now
it doesn't seem to work with action alias. The quick
fix is to check if the action name ends with '!'; if
it does then we need not to set the command.
Regards,
======================= Diff =========================
F:\external_projects\webwork\src\main\webwork\action\factory>cvs
diff CommandAct
ionFactoryProxy.java
Index: CommandActionFactoryProxy.java
===================================================================
RCS file:
/cvsroot/webwork/webwork/src/main/webwork/action/factory/CommandAction
FactoryProxy.java,v
retrieving revision 1.10
diff -r1.10 CommandActionFactoryProxy.java
12a13,15
> import java.util.Set;
> import java.util.Iterator;
>
49,50c52,55
< if (idx != -1)
< {
---
>
> if ( idx == aName.length() - 1 ){
> return
getNextFactory().getActionImpl(aName.substring(0,
idx));
> }else if (idx != -1) {
69a75,87
> }else{
> Set keys =
ActionContext.getContext().getParameters().keySet();
> String keyName;
>
> for ( Iterator iter = keys.iterator();
iter.hasNext(); ){
> keyName = (String) iter.next();
>
> if ( keyName.startsWith("command{")
&& keyName.endsWith("}") )
{
> ((CommandDriven)
action).setCommand(
> keyName.substring(8,
keyName.length() - 1));
> break;
> }
> }
=====
---------------------------------------------
Hai Pham Quang
---------------------------------------------
__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/ |