John,

I've been playing around with your issue on 1.2.4 and it all worked
normally. (code examples and plenty of notes below)

I was able to set the global-forwards parameter "type" to my ActionForward
subclass.  I had to shut down Tomcat completely and start it clean to get
that to work. My ActionForward subclass contained a dump property name, yes,
"property" (i.e. getProperty()/setProperty(String)).  I was also able to set
the ActionForward subclass on an individual forward, both in the
global-forwards section and as a nested (inside the Action declaration)
forward using the className="someActionForwardSubclass" parameter.

There is a second way to globally override forwards in the web.xml by
specifying the "forward" init parameter to the ActionServlet but that DID
NOT work for me.  The notes that this should be possible are in the
struts-config_1_2.tld file:

<!-- The "global-forwards" element describes a set of ActionForward objects
     [org.apache.struts.action.ActionForward] that are available to all
Action
     objects as a return value. The individual ActionForwards are configured
     through nested <forward> elements. An <action> element may override a
global
     forward by defining a local <forward> of the same name.

     type            Fully qualified Java class to use when instantiating
                     ActionForward objects.  If specified, the object must
be a
                     subclass of the default class type.

                     WARNING:  For Struts 1.0, this value is ignored.  You
                     can set the default implementation class name with the
                     "forward" initialization parameter to the Struts
                     controller servlet.
-->

There is nothing in the code.  It looks like the init params "debug",
"detail", and "forward", etc. are no longer valid init-params for the
ActionServlet according to the latest CVS commit at:
http://cvs.apache.org/viewcvs.cgi/jakarta-struts/src/share/org/apache/struts
/action/ActionServlet.java?rev=1.178&only_with_tag=STRUTS_1_2_4&view=auto

If you want the example code that I used, here it is.  My package is
com.friedsoftware.struts.

// my ActionMapping subClass:
// -----------------------------------------------
package com.friedsoftware.struts;
import org.apache.struts.action.ActionMapping;

public class ActionMappingExample extends ActionMapping {
        String commands;

        public String getCommands() {
                return commands;
        }

        public void setCommands(String commands) {
                this.commands = commands;
        }
}

// -----------------------------------------------
// My struts-config.xml global-forwards (which work)
// My action always does a lookup for the mapping "success"
// -----------------------------------------------
<global-forwards>
        <forward name="success"
                className="com.friedsoftware.struts.ActionForwardExample"
                path="/index2.jsp">
                <set-property property="property" value="welcome"/>
        </forward>
</global-forwards>

// -----------------------------------------------
// My struts-config.xml action setup and forward are:
// -----------------------------------------------
    <action
        path="/successDefault"
        validate="false"
                type="com.friedsoftware.struts.ActionExample">
        </action>
    <action
        path="/successOverrideTest"
        validate="false"
                type="com.friedsoftware.struts.ActionExample">
                <forward name="success"
className="com.friedsoftware.struts.ActionForwardExample"
                        path="/index2.jsp">
                        <set-property property="property" value="success"/>
                </forward>
        </action>

// -----------------------------------------------
// My example Action
// -----------------------------------------------
package com.friedsoftware.struts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class ActionExample extends Action {
        private Log log = LogFactory.getLog(this.getClass());

        public ActionForward execute(ActionMapping mapping, ActionForm form,
                        HttpServletRequest request, HttpServletResponse response)
                        throws Exception {
                log.info("Checking mapping: " + request.getPathInfo());
                log.info("Retrieving the ActionForward named 'success'");
                ActionForward am = mapping.findForward("success");
                log.info("---- ActionForward of type: " + am.getClass().toString());

                if (am.getClass().toString().equals(
                                "class 
com.friedsoftware.struts.ActionForwardExample")) {
                        ActionForwardExample newAm = (ActionForwardExample) am;
                        log.info("The cast was successful");
                        log.info("---- Asking for property, it was set to '" +
                                        newAm.getProperty() + "'.");
                        return (newAm);
                }

                return (am);
        }
};

// -----------------------------------------------
// And finally, my logged output showing it works:
// -----------------------------------------------
[INFO] ActionExample - Checking mapping: /successDefault
[INFO] ActionExample - Retrieving the ActionForward named 'success'
[INFO] ActionExample - ---- ActionForward of type: class
com.friedsoftware.struts.ActionForwardExample
[INFO] ActionExample - The cast was successful
[INFO] ActionExample - ---- Asking for property, it was set to 'welcome'.

[INFO] ActionExample - Checking mapping: /successOverrideTest
[INFO] ActionExample - Retrieving the ActionForward named 'success'
[INFO] ActionExample - ---- ActionForward of type: class
com.friedsoftware.struts.ActionForwardExample
[INFO] ActionExample - The cast was successful
[INFO] ActionExample - ---- Asking for property, it was set to 'success'.


// end of all sorts of code...


I hope this 1.2.4 example set helps you.

Regards,
David

-----Original Message-----
From: John Crossman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 15, 2004 5:01 PM
To: Struts Users Mailing List
Subject: Re: CustomActionForward -- How do I pick it up in the Action?


Thanks -- but despite my use of
http://cvs.apache.org/dist/struts/v1.2.4/ that change is causing:

[2004/09/15 13:59:49] Parsing error processing resource path
/WEB-INF/struts-config.xml
javax.servlet.UnavailableException: Parsing error processing resource
path /WEB-INF/struts-config.xml
at
org.apache.struts.action.ActionServlet.handleConfigException(ActionServlet.j
ava:739)
at
org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.j
ava:715)
at
org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:6
70)

Perhaps I'm a little too close to the cutting edge here?! Any other
ideas on how I can get this to work?

J


David G. Friedman wrote:

>I think like so: (Per my Stuts In Action reference pages)
>
><action-mappings>
>       <action path="/Date/SampleView"
>               type="cnwk.camaro.MasterAction"
>               scope="request">
>               <forward
>                       name="success"
>                       className="cnwk.camarao.CustomerActionForward"
>                       path="/WEB-INF/pages/SampleView.jsp" />
>       </action>
></action-mappings>
>
>I'm thinking that without it, how would the Action config
>know to cast it as anything other than a ForwardAction
>instead of a subclass when you call findFoward(...) ?
>
>Regards,
>David
>
>-----Original Message-----
>From: John Crossman [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, September 15, 2004 4:02 PM
>To: Struts Users Mailing List
>Subject: Re: CustomActionForward -- How do I pick it up in the Action?
>
>
>What exactly would that look like?
>
>J
>
>David G. Friedman wrote:
>
>
>
>>Doesn't your Action's nested forward need
>>the attribute "classname=SOMETHING" ?
>>
>>Regards,
>>David
>>
>>-----Original Message-----
>>From: John Crossman [mailto:[EMAIL PROTECTED]
>>Sent: Wednesday, September 15, 2004 3:47 PM
>>To: Struts Users Mailing List
>>Subject: CustomActionForward -- How do I pick it up in the Action?
>>
>>
>>My struts-config has the following:
>>
>>   <global-forwards type="cnwk.camaro.CustomActionForward">
>>       <forward name="DateFormat" path="/do/Date/SampleView" >
>>           <set-property property="commands" value="stuff" />
>>       </forward>
>>   </global-forwards>
>>
>>   <action-mappings>
>>       <action path="/Date/SampleView"
>>           type="cnwk.camaro.MasterAction"
>>           scope="request">
>>           <forward
>>               name="success"
>>               path="/WEB-INF/pages/SampleView.jsp" />
>>       </action>
>>   </action-mappings>
>>
>>And yet the following causes ClassCastException in my MasterAction class:
>>
>>       CustomActionForward customForward = (CustomActionForward)
>>mapping.findForward( DEFAULT_VIEW_KEY );
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
>>
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>


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


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

Reply via email to