Ted --

After refactoring my app to use the S2 Dynamic Method Invocation as follows:

       <action name="course_*" method="{1}" class="course">
           <result name="input">/pages/course.jsp</result>
           <result>/pages/course.jsp</result>
       </action>

I am discovering that both
http://localhost:8080/dsms/course_create.action AND
http://localhost:8080/dsms/course!create.action work the same way.  Is this
a feature?  This is the sort of voodoo that should probably be cast out!

Scott



On 4/6/07, Ted Husted <[EMAIL PROTECTED]> wrote:

There's a feature embedded in WebWork that lets the "!" character
invoke a method other than execute. In WebWork, it doesn't really have
a name. During the S2 discussions, we coined the term "dynamic method
invocation" to describe how WW/S2 use the ! notation.

For Struts 2, we added a switch to disable Dynamic Method Invocation"
for two reasons. First, it can cause security issues if POJO actions
are used. Second, it overlaps with the Wildcard feature that we
brought over from Struts 1 (and from Cocoon before that).

S2 does support  "dynamic method invocation", but there are problems
with the implementation. Essentially, the code scans the action name
for a "!", and finding one, tricks the framework into invoking the
other method instead of execute. The other method is invoked, but it
uses the same configuration as the execute method, including
validations.  The framework "believes" it is invoking the "Category"
action with the execute method.

The Wildcard feature is implemented differently. When a Wildcard
action is invoked, the framework acts as if the matching action had
been hardcoded. The framework "believes" it's executing
"Category!create" and "knows" it is executing the "create" method.
This permits us to add specific validations, localizations, and type
converters, for a Wildcard action, just like a conventional action.

If someone were to implement [WW-1522], then the  "dynamic method
invocation" approach could have its own validations too. Here, the
notion is to generate carbon actions for qualifying methods. The
invocation would no longer be dynamic, because there would be an
actual action in the configuration, but any method could be invoked.

* https://issues.apache.org/struts/browse/WW-1522

My first pass at implementing [WW-1522] didn't work out. Though, I'm
wondering if whatever we do for the codebehind plugin might work here
too. At this point, I will probably never get to it myself, but
perhaps someone will pickup the baton.

In my own applications, I tend to use the underscore ("_") as a
Wildcard separator, to avoid confusion with the WebWork bang. In
practice, these are the only two special characters that work without
causing JavaScript issues.

HTH, Ted
<http://www.husted.com/ted/blog/>


On 4/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> since '!' is already a special character which specifies the method name
> automatically see struts.properties configuration file for more details
> about how to enable/disable dynamic method invocation
>
> Can you explain this?  I read all I could find on this topic and their
was
> discussion dating back to early XWorks changes, however I could not make
> sense out of it.  I do recall changing my struts.properties and it does
seem
> to be working as I hoped.  What is meant by "already a special
character?"
>
> Thanks,
> Scott
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Scott
[EMAIL PROTECTED]

Reply via email to