struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dahnke, Eric (Company IT)" <Eric.Dah...@morganstanley.com>
Subject Extending ActionMapping to use <set-property>
Date Wed, 08 Dec 2004 23:19:46 GMT

Hello,

We would like to introduce a custom parameter into all action's
ActionMappings. I've looked at a bunch of examples and threads, but
can't get it to work. Here's the setup:

Struts-config:
--------------
<action-mappings type="com.foo.bar.actions.CustomActionMapping">
    <action path="/uploadSubmit"
	type="com.ms.promo.actions.UploadAction"
	input="/WEB-INF/web/upload.jsp"
	scope="request"
	name="uploadForm">
        <set-property property="foo" value="bar" />
        <forward name="display" path="/WEB-INF/web/display.jsp" />
    </action>
</action-mappings>


CustomActionMapping:
--------------------
package com.foo.bar.actions;
import org.apache.struts.action.ActionMapping;
public class CustomActionMapping extends ActionMapping {

    protected String foo;
 
    public CustomActionMapping() {
        super();
    }
    public String getFoo() {
        return foo;
    }
    public void setFoo(String foo) {
        this.foo = foo;
    }
}


Upload Action:
--------------
public class UploadAction extends Action {
    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws Exception {

        String forward = "display";
        CustomActionMapping cam = (CustomActionMapping) mapping;

        System.out.println("Foo="+cam.getFoo());
}


cam.getFoo() is always null!?!?


A few questions:
----------------

Is the constructor in CustomActionMapping necessary?

Is the casting of the ActionMapping to CustomActionMapping the way to
get at the getter method of the property that is set? If not how do I
get at the set-property?


What am I missing? Thx, Eric 
--------------------------------------------------------
 
NOTICE: If received in error, please destroy and notify sender.  Sender does not waive confidentiality
or privilege, and use is prohibited. 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message