At 9:58 AM -0800 3/17/05, Dakota Jack wrote:
Cool, I think.  Do you mean you can do this with the <action-mapping>?
 Sorry if this is a really stupid question.  I have not looked at the
configuration of v1.3.  If this is going to be possible, you will have
solved half the qusetions on the list.

Yep: http://svn.apache.org/viewcvs.cgi?rev=111970&view=rev original discussion thread: http://thread.gmane.org/gmane.comp.jakarta.struts.devel/23510

In short, inside an <action> element, you may use:
         <set-property key="command"  value="fooCommand" />

And then in an action...

public ActionForward execute(ActionMapping m, ActionForm f, HttpServletRequest rq, HttpServletResponse rs) {

String commandValue = mapping.getProperty("command"); // commandValue == "fooCommand"

}

Of course, in a chain model, you could do this anywhere you had an ActionContext:

actionContext.getActionConfig().getProperty("command") == "fooCommand



The model I have in mind right now for setting up forms, though, doesn't use the action mapping but rather links the form name to the ForwardConfig. It seems more natural to me to associate the set up with the destination, and it happens once in a while that you have more than one action which processes a request which all forward to the same response/view.

Actually, I don't mean that I would add the arbitrary map to ForwardConfig -- although I have no objection to it -- I'm expecting to write this sometime in the next week or so and commit it unless there's objection.

<action path="/processRequest" name="requestForm" validate="true"...>
<forward name="success" path="/Response.jsp" catalog="pagePrep" command="/Response.jsp" />
</action>


and then in a chain-config.xml:

<catalog name="pagePrep">
  <chain name="/Response.jsp">
    <command className="com.example.SubclassOfFormPrepCommand"
                         name="responseForm"
                         scope="request" />
  </chain>
</catalog>

Then an Abstract class:
package com.example.FormPrepCommand implements ActionCommand extends ActionCommandBase {
private String name = null;
private String scope = "request"; // default
// no need to write the actual property methods...


  public boolean execute(ActionContext context) {
      ActionForm form = lookupForm(this.name, this.scope);
      prepareForm(context, form);
      return false; // never aborts chain
  }

  protected ActionForm lookupForm(String name, String scope) {
     // perform lookup using standard Struts idioms.
   }
  protected abstract void prepareForm(ActionContext context, ActionForm form);

}

Last time I mentioned this it got some positive feedback and no negative comments.

Joe
--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Narrow minds are weapons made for mass destruction" -The Ex


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



Reply via email to