>From the looks of it, your tag class is trying to call the getRequest()
method of the action class.  That's completely unnecessary.  It could
access the "data" property as it would for any pojo variable.  No need
to deal with the request, much less the action class or any of its
methods.

BTW, Dave Newton's suggestion of using ${ propertyname } is the way to
go, assuming you're on a 2.3 servlet container.  I completely overlooked
the simple approach.  


-----Original Message-----
From: Dominik Fischer [mailto:fische...@idowa.de] 
Sent: Thursday, February 05, 2009 11:20 AM
To: Struts Users Mailing List
Subject: Re: Access Struts2 Action Properties - Noob

Ok. Your idea worked allready. But know i have more properties to 
transport. What do you say about following construction:

/****Example Action****/
public class EAction extends ActionSupport implements RequestAware {
        private List data;
        private Map<String, Object> request;

        public void setRequest(Map<String, Object> request) {
                this.request = request;
        }

        public Map<String, Object> getRequest() {
                return request;
        }

        public String execute() {
                getRequest().put("currentAction",this);
                return SUCCESS;
        }
}

/****Example Tag****/
public class ETag extends TagSupport {
        pirvate String action;
        
        //Getter/Setter start
        ....
        //Getter/Setter end

        public int doStartTag() throws JspException {
                Object oAction =
                pageContext.getRequest().getAttribute(getRequest());
                
                if(oAction != null && oAction instanceof EAction) {
                        EAction eAction = (EAction) oAction;
                        //Then do something
                }
                return SKIP_BODY;
        }
}

I think this will work, but is there a better and propere construct?




Kawczynski, David schrieb:
> You can have your actionsupport subclass implement the 
> org.apache.struts2.interceptor.RequestAware interface 
> 
> This means your class will automatically get a Map which 
> is bound to the request attributes.  You can add things 
> to that map and they will be set as request attributes.
> 
> And the good news it, because it's a Map it plays well
> with junit without having to mock anything up.
> 
> 
> -----Original Message-----
> From: Dominik Fischer [mailto:fische...@idowa.de] 
> Sent: Thursday, February 05, 2009 10:57 AM
> To: Struts Users Mailing List
> Subject: Re: Access Struts2 Action Properties - Noob
> 
> Thank you,
> that is a first help. But is there a possibility without using tags
from
> 
> Struts? I don't know, i'm dreaming of things like 
> strutsActionSession.getAttribute("data"). Do you know something like
> this?
> 
> 
> 
> Kawczynski, David schrieb:
>> http://struts.apache.org/2.0.14/docs/set.html
>>
>>
>> -----Original Message-----
>> From: Dominik Fischer [mailto:fische...@idowa.de] 
>> Sent: Thursday, February 05, 2009 8:59 AM
>> To: user@struts.apache.org
>> Subject: Access Struts2 Action Properties - Noob
>>
>> Hello folks,
>>
>> how can i access a property (i.e. data) of a class like....
>>
>> public class BabyAction extends ActionSupport implements RequestAware
> {
>>      private List data;
>>
>>      public List getData() {
>>              return this.data;
>>      }
>>
>>      public void setSearch(List data) {
>>              this.data = data;
>>      }
>>
>>      ...
>>
>> }
>>
>> ... in a custom tag like ...
>>      <i:divTable list="data"/>
>> ... without the help of request.setParameter() i.e.
>> ?????
>>
>>
>>
>> Thankz
>> Dom
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>> Notice:  This e-mail message, together with any attachments, contains
>> information of Merck & Co., Inc. (One Merck Drive, Whitehouse
Station,
>> New Jersey, USA 08889), and/or its affiliates (which may be known
>> outside the United States as Merck Frosst, Merck Sharp & Dohme or
>> MSD and in Japan, as Banyu - direct contact information for
affiliates
> is
>> available at http://www.merck.com/contact/contacts.html) that may be
>> confidential, proprietary copyrighted and/or legally privileged. It
is
>> intended solely for the use of the individual or entity named on this
>> message. If you are not the intended recipient, and have received
this
>> message in error, please notify us immediately by reply e-mail and
>> then delete it from your system.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
> Notice:  This e-mail message, together with any attachments, contains
> information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
> New Jersey, USA 08889), and/or its affiliates (which may be known
> outside the United States as Merck Frosst, Merck Sharp & Dohme or
> MSD and in Japan, as Banyu - direct contact information for affiliates
is
> available at http://www.merck.com/contact/contacts.html) that may be
> confidential, proprietary copyrighted and/or legally privileged. It is
> intended solely for the use of the individual or entity named on this
> message. If you are not the intended recipient, and have received this
> message in error, please notify us immediately by reply e-mail and
> then delete it from your system.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
> 


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

Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or
MSD and in Japan, as Banyu - direct contact information for affiliates is
available at http://www.merck.com/contact/contacts.html) that may be
confidential, proprietary copyrighted and/or legally privileged. It is
intended solely for the use of the individual or entity named on this
message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and
then delete it from your system.


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

Reply via email to