Hi,

You have to write your own ActionMapping implementation like below.

eg:-

public class MyOwnActionMapping extends ActionMapping{
    
    private String myProperty;
    
    /** Creates a new instance of MyOwnActionMapping */
    public MyOwnActionMapping() {
    }

    public String getMyProperty() {
        return myProperty;
    }

    public void setMyProperty(String myProperty) {
        this.myProperty = myProperty;
    }
    
}

and then in your struts config you have to specify that your using your own 
ActionMappping implementation

    <action-mappings type="com.myapp.struts.MyOwnActionMapping">

        <action input="/welcomeStruts.jsp" name="TestForm" path="/myaction" 
scope="request" type="com.myapp.struts.MyAction" validate="false">
            <set-property property="myProperty" value="This is cool"/>
            <forward name="success" path="/index.jsp"/>
            <forward name="failed" path="/welcomeStruts.jsp"/>
        </action>
    </action-mappings>

In you your action class you have to do something like this.

    public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
        MyOwnActionMapping mapping2 = (MyOwnActionMapping)mapping;
        
        System.out.println("My property in action 
is:"+mapping2.getMyProperty()); 
               
        return mapping.findForward(FAILED);
        
    }

Thanks,

Nuwan.

  ----- Original Message ----- 
  From: Carl Smith 
  To: Nuwan Chandrasoma 
  Sent: Friday, January 19, 2007 3:19 AM
  Subject: Re: How to get the property value in action


  I like the first approach since I am not using struts 1.3. However it doesn't 
work. 

  What do you mean by "your own ActionMapping implementation"?

  Nuwan Chandrasoma <[EMAIL PROTECTED]> wrote:
    Hi,

    below code is that you have used your own ActionMapping implementation, but 
    if you have used struts 1.3 you can use the method getProperty() in 
    ActionMapping class. for eg:

    mappnig.getProperty("myProperty");

    Thanks,

    Nuwan.


    ----- Original Message ----- 
    From: "Nuwan Chandrasoma" 
    To: "Struts Users Mailing List" 
    Sent: Friday, January 19, 2007 7:33 AM
    Subject: Re: How to get the property value in action


    > Hi,
    >
    > Inside you action class execute method
    >
    > mapping.getMyProperty();
    >
    > Thanks,
    >
    > Nuwan.
    >
    >
    > ----- Original Message ----- 
    > From: "Zhang, Larry (L.)" 
    > To: "Struts Users Mailing List" 
    > Sent: Thursday, January 18, 2007 10:59 PM
    > Subject: How to get the property value in action
    >
    >
    > I have the following action mapping, how to get the property value of
    > myProperty in action?
    >
    > Thanks.
    >
    > > type="com.....MaintainMyProcessAction" parameter="method">
    > > value="myPropertyValue"/>
    > 
    >
    > ---------------------------------------------------------------------
    > 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]






------------------------------------------------------------------------------
  TV dinner still cooling?
  Check out "Tonight's Picks" on Yahoo! TV.

Reply via email to