You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Igor Vlasov <vi...@mail.ru> on 2007/10/10 16:33:24 UTC

Manually obtain previous action parameters after action "chaining"?

I have action "one" and it calls action "two" throw:
 <result  name="success" type="chain" >two</result>


I can use ChainingInterceptor to copy properties of "one" action to "two"
action.

I get behaviour : one.param->two.param. 
But the property "param" must be in  javaBeans specification(have setter and
getter method for each property).

Can i MANUALLY get object for "one" action or exact "one.property" from
:"execute()" method of action "two"?


-- 
View this message in context: http://www.nabble.com/Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13136989
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Manually obtain previous action parameters after action "chaining"?

Posted by Dave Newton <ne...@yahoo.com>.
You could try exposing ActionSupport's
actionMessages/fieldErrors/etc by putting getters in
your first action; I'm not quite sure how the chain
interceptor decides how to copy properties though.

d.

--- jjgould <jj...@pobox.com> wrote:

> 
> Ted, et. al.,
> 
> I am also interested in accessing the previous
> action from the target action
> of a "chain" result.  But, the reason I want to get
> to that action is not
> because of any bean properties, but because I need
> the action errors, action
> messages, and field errors that may have been placed
> there by my validation.
> 
> In my case, action "one" is used to view an object
> that is an aggregate of a
> lot of smaller objects.  Action "two" is used to add
> a new component object
> to the collection.  However, when there is a
> validation error on the new
> object, the application needs to forward back to
> action "one" to redisplay
> the object and it needs to have the field error
> messages.  The struts.xml
> looks like this:
> 
>         <action
>             name="*/view"
>            
> class="com.sherwin.sd.eris.web.action.CaseAction"
>             method="execute">
>             {1}
>             <result
>
name="success">/WEB-INF/jsp/case/viewCase.jsp</result>
>         </action>
> 
>         <action
>             name="*/issue/add"
>            
> class="com.sherwin.sd.eris.web.action.IssueAction"
>             method="addIssue">
>             {1}
>             <result
>                 name="input"
>                 type="chain">
>                 {1}/view
>             </result>
>             <result
>                 name="success"
>                 type="redirect-action">
>                 {1}/view
>             </result>
>         </action>
> 
> Any tips you can offer are greatly appreciated.
> 
> - Jack Gould
>   Sherwin-Williams
>   Cleveland, Ohio, USA
> 
> 
> Ted Husted wrote:
> > 
> > Binding two Action classes together that way
> sounds like a "slippery
> > slope" to me. It seems like a better practice to
> rely on standard
> > JavaBean semantics, and access the values that
> need to be brought
> > forward through the usual get and set methods.
> > 
> > One other thing to try, which you may have started
> to do, would be to
> > save the object as a request attribute, as an
> alternative to the chain
> > result. In this case, both Actions would have
> setRequest and
> > getRequest methods.
> > 
> > ActionOne
> > 
>
getRequest().put("searchParameter",getSearchParameter());
> > 
> > ActionTwo
> >  setSearchParameter( (SearchParameter)
> getRequest().get("searchParameter")
> > );
> > 
> > The JVM is optimized for property methods, and
> overall it's a better
> > practice to go through the getters and setters
> than access fields
> > directly.
> > 
> > -- HTH, Ted
> > <http://www.husted.com/ted/blog/>
> > 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/-S2--Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13640692
> Sent from the Struts - User mailing list archive at
> Nabble.com.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 


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


Re: Manually obtain previous action parameters after action "chaining"?

Posted by jjgould <jj...@pobox.com>.
There was a good suggestion about using the MessageStoreInterceptor, but I am
really trying to avoid using Session-based storage for my application,
having been indoctrinated into the RESTful camp at the 2007 Colorado
Software Summit :)

I just discovered that both actions (the one that gets the validation errors
and the target of the chain result) are on the OGNL stack.  So, here is what
I did:



>     @Override
>     public String execute()
>         throws Exception
>     {
>         ValueStack stack = ActionContext.getContext().getValueStack();
>         Object penultimate = stack.findValue( "[1].top" );
>         if( penultimate instanceof ValidationAware )
>         {
>             ValidationAware previousAction = (ValidationAware)
> penultimate;
>             this.setActionErrors( previousAction.getActionErrors() );
>             this.setActionMessages( previousAction.getActionMessages() );
>             this.setFieldErrors( previousAction.getFieldErrors() );
>         }
>         return SUCCESS;
>     }
> 

I like this approach because it seems clean.  But, I am wondering, given the
fact that bean properties are set in the second action, why aren't
"actionErrors", "actionMessages", and "fieldErrors" seen as bean properties
that get automatically set by the ChainingInterceptor?

Anyway, this solution is working for me, and I think I should abstract this
out into an interceptor so that I don't have to pollute my action methods
with this logic.  Does anyone have any feedback about this approach?  Am I
abusing the OGNL stack?  Am I breaking semantics of validation handling?  Is
it possible that the first action will not be located on the stack as
"[1].top"?

Thanks for your help!


jjgould wrote:
> 
> Ted, et. al.,
> 
> I am also interested in accessing the previous action from the target
> action of a "chain" result.  But, the reason I want to get to that action
> is not because of any bean properties, but because I need the action
> errors, action messages, and field errors that may have been placed there
> by my validation.
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13647964
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Manually obtain previous action parameters after action "chaining"?

Posted by Gary Affonso <gl...@greywether.com>.
You can preserve errors and messages from one action to another, across 
a redirect, with the MessageStoreInterceptor.  See here:

   http://struts.apache.org/2.x/docs/message-store-interceptor.html

This lets you avoid chaining which, of course, is usually evil. :-)

- Gary

jjgould wrote:
> Ted, et. al.,
> 
> I am also interested in accessing the previous action from the target action
> of a "chain" result.  But, the reason I want to get to that action is not
> because of any bean properties, but because I need the action errors, action
> messages, and field errors that may have been placed there by my validation.
> 
> In my case, action "one" is used to view an object that is an aggregate of a
> lot of smaller objects.  Action "two" is used to add a new component object
> to the collection.  However, when there is a validation error on the new
> object, the application needs to forward back to action "one" to redisplay
> the object and it needs to have the field error messages.  The struts.xml
> looks like this:
> 
>         <action
>             name="*/view"
>             class="com.sherwin.sd.eris.web.action.CaseAction"
>             method="execute">
>             {1}
>             <result name="success">/WEB-INF/jsp/case/viewCase.jsp</result>
>         </action>
> 
>         <action
>             name="*/issue/add"
>             class="com.sherwin.sd.eris.web.action.IssueAction"
>             method="addIssue">
>             {1}
>             <result
>                 name="input"
>                 type="chain">
>                 {1}/view
>             </result>
>             <result
>                 name="success"
>                 type="redirect-action">
>                 {1}/view
>             </result>
>         </action>
> 
> Any tips you can offer are greatly appreciated.
> 
> - Jack Gould
>   Sherwin-Williams
>   Cleveland, Ohio, USA
> 
> 
> Ted Husted wrote:
>> Binding two Action classes together that way sounds like a "slippery
>> slope" to me. It seems like a better practice to rely on standard
>> JavaBean semantics, and access the values that need to be brought
>> forward through the usual get and set methods.
>>
>> One other thing to try, which you may have started to do, would be to
>> save the object as a request attribute, as an alternative to the chain
>> result. In this case, both Actions would have setRequest and
>> getRequest methods.
>>
>> ActionOne
>>  getRequest().put("searchParameter",getSearchParameter());
>>
>> ActionTwo
>>  setSearchParameter( (SearchParameter) getRequest().get("searchParameter")
>> );
>>
>> The JVM is optimized for property methods, and overall it's a better
>> practice to go through the getters and setters than access fields
>> directly.
>>
>> -- HTH, Ted
>> <http://www.husted.com/ted/blog/>
>>
> 


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


Re: Manually obtain previous action parameters after action "chaining"?

Posted by jjgould <jj...@pobox.com>.
Ted, et. al.,

I am also interested in accessing the previous action from the target action
of a "chain" result.  But, the reason I want to get to that action is not
because of any bean properties, but because I need the action errors, action
messages, and field errors that may have been placed there by my validation.

In my case, action "one" is used to view an object that is an aggregate of a
lot of smaller objects.  Action "two" is used to add a new component object
to the collection.  However, when there is a validation error on the new
object, the application needs to forward back to action "one" to redisplay
the object and it needs to have the field error messages.  The struts.xml
looks like this:

        <action
            name="*/view"
            class="com.sherwin.sd.eris.web.action.CaseAction"
            method="execute">
            {1}
            <result name="success">/WEB-INF/jsp/case/viewCase.jsp</result>
        </action>

        <action
            name="*/issue/add"
            class="com.sherwin.sd.eris.web.action.IssueAction"
            method="addIssue">
            {1}
            <result
                name="input"
                type="chain">
                {1}/view
            </result>
            <result
                name="success"
                type="redirect-action">
                {1}/view
            </result>
        </action>

Any tips you can offer are greatly appreciated.

- Jack Gould
  Sherwin-Williams
  Cleveland, Ohio, USA


Ted Husted wrote:
> 
> Binding two Action classes together that way sounds like a "slippery
> slope" to me. It seems like a better practice to rely on standard
> JavaBean semantics, and access the values that need to be brought
> forward through the usual get and set methods.
> 
> One other thing to try, which you may have started to do, would be to
> save the object as a request attribute, as an alternative to the chain
> result. In this case, both Actions would have setRequest and
> getRequest methods.
> 
> ActionOne
>  getRequest().put("searchParameter",getSearchParameter());
> 
> ActionTwo
>  setSearchParameter( (SearchParameter) getRequest().get("searchParameter")
> );
> 
> The JVM is optimized for property methods, and overall it's a better
> practice to go through the getters and setters than access fields
> directly.
> 
> -- HTH, Ted
> <http://www.husted.com/ted/blog/>
> 

-- 
View this message in context: http://www.nabble.com/-S2--Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13640692
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Manually obtain previous action parameters after action "chaining"?

Posted by Ted Husted <hu...@apache.org>.
Binding two Action classes together that way sounds like a "slippery
slope" to me. It seems like a better practice to rely on standard
JavaBean semantics, and access the values that need to be brought
forward through the usual get and set methods.

One other thing to try, which you may have started to do, would be to
save the object as a request attribute, as an alternative to the chain
result. In this case, both Actions would have setRequest and
getRequest methods.

ActionOne
 getRequest().put("searchParameter",getSearchParameter());

ActionTwo
 setSearchParameter( (SearchParameter) getRequest().get("searchParameter") );

The JVM is optimized for property methods, and overall it's a better
practice to go through the getters and setters than access fields
directly.

-- HTH, Ted
<http://www.husted.com/ted/blog/>


On 10/11/07, Igor Vlasov <vi...@mail.ru> wrote:
>
> Thank you for the answer.
>
> I see that properties are copied. But the property must be in javaBean spec.
> otherwise subpropirties are not copied. I think that i can get previos
> Action and manualy get whole property as object. The copy process in
> ChainInterceptor rely on OGNL and  look like "magik".
>
> If there is not any ability to get a previous action  and its properties
> manually after ChainResult, I agree to rely on  ChainInterceptor.
>
> I posted a detailed message
> http://www.nabble.com/-S2--NULL-Session-object-after-execAndWait-interceptor.-Why--tf4600442.html
> about session object and strange behavior after execAndWait interceptor
>
>
> Ted Husted wrote:
> >
> > The Action itself is not copied over, the PROPERTIES are copied. If
> > the properties in common are copied forward, then there should be no
> > need to address the prior Action class directly. Any methods that need
> > to be called by more than one Action should be moved to a base support
> > class that the Actions can share.
> >
> > Also, there is rarely a need to use HTTP semantic in a Struts 2
> > Action. The SessionAware and RequestAware interceptors expose the
> > session and request attributes as entries in Maps. request.getSession
> > doesn't work, because the interceptor doesn't pass the HttpRequest
> > object but a map the proxies the attributes in request scope. If the
> > Action needs access to the session attributes, then implement
> > setSession(Map).
> >
> > -Ted.
> >
> >
> > On 10/11/07, Igor Vlasov <vi...@mail.ru> wrote:
> >>
> >> 1. I have "actionOne"
> >>
> >> public class ActionOne extends ActionSupport implements
> >> ServletRequestAware{
> >>   protected HttpServletRequest request;
> >>
> >>   private SearchParameter searchData=new SearchParameter();//My complex
> >> object
> >>
> >>   public String execute() throws Exception{
> >>      //fill searchData with parameters. Many many parameters.....
> >>       return this.SUCCESS;
> >>   }
> >>
> >>   // this is for ability to copy object searchData to next chain action
> >>   public SearchParameter getSearchData() {
> >>     return searchData;
> >>   }
> >>
> >>   public void setServletRequest(HttpServletRequest httpServletRequest) {
> >>     request = httpServletRequest;
> >>   }
> >>
> >> }
> >>
> >> 2.
> >>   <package name="searchEngine" namespace="/s2examples"
> >> extends="struts-default">
> >>     <action name="*search" class="s2.action.ActionOne" method="{1}"  >
> >>       <result  name="success" type="chain" >doSearch</result><!--to
> >> search
> >> -->
> >>       <result  name="input" >search.jsp</result> <!--input -->
> >>     </action>
> >>     <!-- специально сделана отдельно, чтобы на нее наложить execAndWait
> >> -->
> >>     <action name="doSearch" class="s2.action.ActionTwo"  >
> >>       <interceptor-ref name="completeStack"/>
> >>       <interceptor-ref name="execAndWait">
> >>         2000
> >>         500
> >>       </interceptor-ref>
> >>       <result  name="wait">wait_search.jsp</result>
> >>       <result  name="success" type="redirect"
> >> >search_result.jsp</result>
> >>     </action>
> >>   </package>
> >>
> >> 3.
> >> public class ActionTwo  extends ActionSupport implements
> >> ServletRequestAware
> >> {
> >>   protected HttpServletRequest request;
> >>   private SearchParameter searchData;
> >>   private HttpSession sess;
> >>   public String execute() throws Exception{
> >>      sess = request.getSession();
> >>      boolean v =(searchData!=null);// ok. we recieve a copy of searchData
> >> from previos action
> >>      try {  Thread.currentThread().sleep(6*1000);  } catch
> >> (InterruptedException ex) {}
> >>      sess = request.getSession(); // return null object!!! why ?
> >>      return this.SUCCESS;
> >>   }
> >>   /*this work and  searchData object has been copied from previos action
> >> */
> >>   public void setSearchData(SearchParameter searchData) {
> >>     this.searchData = searchData;
> >>   }
> >> }
> >>
> >> The desired behaviour:
> >>
> >> public class ActionTwo  extends ActionSupport implements
> >> ServletRequestAware
> >> {
> >>   protected HttpServletRequest request;
> >>   private HttpSession sess;
> >>   public String execute() throws Exception{
> >>      SearchParameter searchData=null;
> >>      try {  Thread.currentThread().sleep(6*1000);  } catch
> >> (InterruptedException ex) {}
> >>      //!!!!
> >>       ActionOne prev=null;
> >>       prev=(ActionOne)getPreviousAction();
> >>       searchData=prev.getSearchData();
> >>      //!!!!
> >>      sess = request.getSession(); // return null object!!! why ?
> >>      return this.SUCCESS;
> >>   }
> >>
> >> }
> >> ===============================================================
> >> for simplisity simplicity searchData may be a simple Object().
> >> I need an ability to make : prev=(ActionOne)getPreviousAction();

Re: Manually obtain previous action parameters after action "chaining"?

Posted by Igor Vlasov <vi...@mail.ru>.
Thank you for the answer.

I see that properties are copied. But the property must be in javaBean spec.
otherwise subpropirties are not copied. I think that i can get previos
Action and manualy get whole property as object. The copy process in
ChainInterceptor rely on OGNL and  look like "magik".

If there is not any ability to get a previous action  and its properties
manually after ChainResult, I agree to rely on  ChainInterceptor.

I posted a detailed message 
http://www.nabble.com/-S2--NULL-Session-object-after-execAndWait-interceptor.-Why--tf4600442.html 
about session object and strange behavior after execAndWait interceptor  


Ted Husted wrote:
> 
> The Action itself is not copied over, the PROPERTIES are copied. If
> the properties in common are copied forward, then there should be no
> need to address the prior Action class directly. Any methods that need
> to be called by more than one Action should be moved to a base support
> class that the Actions can share.
> 
> Also, there is rarely a need to use HTTP semantic in a Struts 2
> Action. The SessionAware and RequestAware interceptors expose the
> session and request attributes as entries in Maps. request.getSession
> doesn't work, because the interceptor doesn't pass the HttpRequest
> object but a map the proxies the attributes in request scope. If the
> Action needs access to the session attributes, then implement
> setSession(Map).
> 
> -Ted.
> 
> 
> On 10/11/07, Igor Vlasov <vi...@mail.ru> wrote:
>>
>> 1. I have "actionOne"
>>
>> public class ActionOne extends ActionSupport implements
>> ServletRequestAware{
>>   protected HttpServletRequest request;
>>
>>   private SearchParameter searchData=new SearchParameter();//My complex
>> object
>>
>>   public String execute() throws Exception{
>>      //fill searchData with parameters. Many many parameters.....
>>       return this.SUCCESS;
>>   }
>>
>>   // this is for ability to copy object searchData to next chain action
>>   public SearchParameter getSearchData() {
>>     return searchData;
>>   }
>>
>>   public void setServletRequest(HttpServletRequest httpServletRequest) {
>>     request = httpServletRequest;
>>   }
>>
>> }
>>
>> 2.
>>   <package name="searchEngine" namespace="/s2examples"
>> extends="struts-default">
>>     <action name="*search" class="s2.action.ActionOne" method="{1}"  >
>>       <result  name="success" type="chain" >doSearch</result><!--to
>> search
>> -->
>>       <result  name="input" >search.jsp</result> <!--input -->
>>     </action>
>>     <!-- специально сделана отдельно, чтобы на нее наложить execAndWait
>> -->
>>     <action name="doSearch" class="s2.action.ActionTwo"  >
>>       <interceptor-ref name="completeStack"/>
>>       <interceptor-ref name="execAndWait">
>>         2000
>>         500
>>       </interceptor-ref>
>>       <result  name="wait">wait_search.jsp</result>
>>       <result  name="success" type="redirect" 
>> >search_result.jsp</result>
>>     </action>
>>   </package>
>>
>> 3.
>> public class ActionTwo  extends ActionSupport implements
>> ServletRequestAware
>> {
>>   protected HttpServletRequest request;
>>   private SearchParameter searchData;
>>   private HttpSession sess;
>>   public String execute() throws Exception{
>>      sess = request.getSession();
>>      boolean v =(searchData!=null);// ok. we recieve a copy of searchData
>> from previos action
>>      try {  Thread.currentThread().sleep(6*1000);  } catch
>> (InterruptedException ex) {}
>>      sess = request.getSession(); // return null object!!! why ?
>>      return this.SUCCESS;
>>   }
>>   /*this work and  searchData object has been copied from previos action
>> */
>>   public void setSearchData(SearchParameter searchData) {
>>     this.searchData = searchData;
>>   }
>> }
>>
>> The desired behaviour:
>>
>> public class ActionTwo  extends ActionSupport implements
>> ServletRequestAware
>> {
>>   protected HttpServletRequest request;
>>   private HttpSession sess;
>>   public String execute() throws Exception{
>>      SearchParameter searchData=null;
>>      try {  Thread.currentThread().sleep(6*1000);  } catch
>> (InterruptedException ex) {}
>>      //!!!!
>>       ActionOne prev=null;
>>       prev=(ActionOne)getPreviousAction();
>>       searchData=prev.getSearchData();
>>      //!!!!
>>      sess = request.getSession(); // return null object!!! why ?
>>      return this.SUCCESS;
>>   }
>>
>> }
>> ===============================================================
>> for simplisity simplicity searchData may be a simple Object().
>> I need an ability to make : prev=(ActionOne)getPreviousAction();
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13155261
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Manually obtain previous action parameters after action "chaining"?

Posted by Ted Husted <hu...@apache.org>.
The Action itself is not copied over, the PROPERTIES are copied. If
the properties in common are copied forward, then there should be no
need to address the prior Action class directly. Any methods that need
to be called by more than one Action should be moved to a base support
class that the Actions can share.

Also, there is rarely a need to use HTTP semantic in a Struts 2
Action. The SessionAware and RequestAware interceptors expose the
session and request attributes as entries in Maps. request.getSession
doesn't work, because the interceptor doesn't pass the HttpRequest
object but a map the proxies the attributes in request scope. If the
Action needs access to the session attributes, then implement
setSession(Map).

-Ted.


On 10/11/07, Igor Vlasov <vi...@mail.ru> wrote:
>
> 1. I have "actionOne"
>
> public class ActionOne extends ActionSupport implements ServletRequestAware{
>   protected HttpServletRequest request;
>
>   private SearchParameter searchData=new SearchParameter();//My complex
> object
>
>   public String execute() throws Exception{
>      //fill searchData with parameters. Many many parameters.....
>       return this.SUCCESS;
>   }
>
>   // this is for ability to copy object searchData to next chain action
>   public SearchParameter getSearchData() {
>     return searchData;
>   }
>
>   public void setServletRequest(HttpServletRequest httpServletRequest) {
>     request = httpServletRequest;
>   }
>
> }
>
> 2.
>   <package name="searchEngine" namespace="/s2examples"
> extends="struts-default">
>     <action name="*search" class="s2.action.ActionOne" method="{1}"  >
>       <result  name="success" type="chain" >doSearch</result><!--to search
> -->
>       <result  name="input" >search.jsp</result> <!--input -->
>     </action>
>     <!-- специально сделана отдельно, чтобы на нее наложить execAndWait -->
>     <action name="doSearch" class="s2.action.ActionTwo"  >
>       <interceptor-ref name="completeStack"/>
>       <interceptor-ref name="execAndWait">
>         2000
>         500
>       </interceptor-ref>
>       <result  name="wait">wait_search.jsp</result>
>       <result  name="success" type="redirect"  >search_result.jsp</result>
>     </action>
>   </package>
>
> 3.
> public class ActionTwo  extends ActionSupport implements ServletRequestAware
> {
>   protected HttpServletRequest request;
>   private SearchParameter searchData;
>   private HttpSession sess;
>   public String execute() throws Exception{
>      sess = request.getSession();
>      boolean v =(searchData!=null);// ok. we recieve a copy of searchData
> from previos action
>      try {  Thread.currentThread().sleep(6*1000);  } catch
> (InterruptedException ex) {}
>      sess = request.getSession(); // return null object!!! why ?
>      return this.SUCCESS;
>   }
>   /*this work and  searchData object has been copied from previos action */
>   public void setSearchData(SearchParameter searchData) {
>     this.searchData = searchData;
>   }
> }
>
> The desired behaviour:
>
> public class ActionTwo  extends ActionSupport implements ServletRequestAware
> {
>   protected HttpServletRequest request;
>   private HttpSession sess;
>   public String execute() throws Exception{
>      SearchParameter searchData=null;
>      try {  Thread.currentThread().sleep(6*1000);  } catch
> (InterruptedException ex) {}
>      //!!!!
>       ActionOne prev=null;
>       prev=(ActionOne)getPreviousAction();
>       searchData=prev.getSearchData();
>      //!!!!
>      sess = request.getSession(); // return null object!!! why ?
>      return this.SUCCESS;
>   }
>
> }
> ===============================================================
> for simplisity simplicity searchData may be a simple Object().
> I need an ability to make : prev=(ActionOne)getPreviousAction();

Re: Manually obtain previous action parameters after action "chaining"?

Posted by Igor Vlasov <vi...@mail.ru>.
1. I have "actionOne"

public class ActionOne extends ActionSupport implements ServletRequestAware{
  protected HttpServletRequest request;

  private SearchParameter searchData=new SearchParameter();//My complex
object

  public String execute() throws Exception{
     //fill searchData with parameters. Many many parameters.....
      return this.SUCCESS;
  }

  // this is for ability to copy object searchData to next chain action 
  public SearchParameter getSearchData() {
    return searchData;
  }

  public void setServletRequest(HttpServletRequest httpServletRequest) {
    request = httpServletRequest; 
  }
  
}

2.
  <package name="searchEngine" namespace="/s2examples"
extends="struts-default">
    <action name="*search" class="s2.action.ActionOne" method="{1}"  >
      <result  name="success" type="chain" >doSearch</result><!--to search
-->
      <result  name="input" >search.jsp</result> <!--input -->
    </action>
    <!-- специально сделана отдельно, чтобы на нее наложить execAndWait -->
    <action name="doSearch" class="s2.action.ActionTwo"  >
      <interceptor-ref name="completeStack"/>
      <interceptor-ref name="execAndWait">
        2000
        500 
      </interceptor-ref>
      <result  name="wait">wait_search.jsp</result>
      <result  name="success" type="redirect"  >search_result.jsp</result>
    </action>
  </package>

3.
public class ActionTwo  extends ActionSupport implements ServletRequestAware
{
  protected HttpServletRequest request;
  private SearchParameter searchData;
  private HttpSession sess;
  public String execute() throws Exception{
     sess = request.getSession();
     boolean v =(searchData!=null);// ok. we recieve a copy of searchData
from previos action
     try {  Thread.currentThread().sleep(6*1000);  } catch
(InterruptedException ex) {}
     sess = request.getSession(); // return null object!!! why ?
     return this.SUCCESS;
  }
  /*this work and  searchData object has been copied from previos action */
  public void setSearchData(SearchParameter searchData) {
    this.searchData = searchData;
  }
}

The desired behaviour:

public class ActionTwo  extends ActionSupport implements ServletRequestAware
{
  protected HttpServletRequest request;
  private HttpSession sess;
  public String execute() throws Exception{
     SearchParameter searchData=null;
     try {  Thread.currentThread().sleep(6*1000);  } catch
(InterruptedException ex) {}
     //!!!!    
      ActionOne prev=null;
      prev=(ActionOne)getPreviousAction();
      searchData=prev.getSearchData();
     //!!!!
     sess = request.getSession(); // return null object!!! why ?
     return this.SUCCESS;
  }
 
}
===============================================================
for simplisity simplicity searchData may be a simple Object().
I need an ability to make : prev=(ActionOne)getPreviousAction();


Laurie Harper wrote:
> 
> Igor Vlasov wrote:
>> Copying of properties with ChainingInterceptor  working GOOD.
> 
> OK, good that something is working well. What's not clear is what 
> *isn't* working...
> 
> Can you post code that works (as a semplar), and then a sample of the 
> code you'd like to write instead (to illustrate what you're looking for)?
> 
> L.
> 
>>>> I have action "one" and it calls action "two" throw:
>>>>  <result  name="success" type="chain" >two</result>
>>>>
>>>>
>>>> I can use ChainingInterceptor to copy properties of "one" action to
>>>> "two"
>>>> action.
>>>>
>>>> I get behaviour : one.param->two.param.
>>>> But the property "param" must be in  javaBeans specification(have
>>>> setter
>>>> and
>>>> getter method for each property).
>>>>
>>>> Can i MANUALLY get object for "one" action or exact "one.property" from
>>>> :"execute()" method of action "two"?
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13152366
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Manually obtain previous action parameters after action "chaining"?

Posted by Laurie Harper <la...@holoweb.net>.
Igor Vlasov wrote:
> Copying of properties with ChainingInterceptor  working GOOD.

OK, good that something is working well. What's not clear is what 
*isn't* working...

> I have very complex object as a property to copy and i MUST make every part
> of it in javaBean specification. For me it is too tedious. Then  i want
> manually copy whole property from  actionOne to  actionTwo.
> 
> The second cause is process of copying. It is sometime like "magic" and copy
> many objects (from action support itself.). And i want to copy just one my
> property.

Can you post code that works (as a semplar), and then a sample of the 
code you'd like to write instead (to illustrate what you're looking for)?

L.

> Ted Husted wrote:
>> The use case for the chain result is that JavaBean properties on
>> ActionTwo that match JavaBean properties on ActionOne are copied
>> forward. This sounds like the same use case that you describe, and
>> it's unclear why it isn't working, or why you would need to do
>> anything manually.
>>
>> The most helpful thing would be to include the relevant source code
>> from your Actions and struts.xml
>>
>> HTH, Ted.
>> http://www.catb.org/~esr/faqs/smart-questions.html
>>
>>
>> On 10/10/07, Igor Vlasov <vi...@mail.ru> wrote:
>>> I have action "one" and it calls action "two" throw:
>>>  <result  name="success" type="chain" >two</result>
>>>
>>>
>>> I can use ChainingInterceptor to copy properties of "one" action to "two"
>>> action.
>>>
>>> I get behaviour : one.param->two.param.
>>> But the property "param" must be in  javaBeans specification(have setter
>>> and
>>> getter method for each property).
>>>
>>> Can i MANUALLY get object for "one" action or exact "one.property" from
>>> :"execute()" method of action "two"?
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13136989
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> -- 
>> HTH, Ted <http://www.husted.com/ted/blog/>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
> 


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


Re: Manually obtain previous action parameters after action "chaining"?

Posted by Igor Vlasov <vi...@mail.ru>.
Copying of properties with ChainingInterceptor  working GOOD.
I have very complex object as a property to copy and i MUST make every part
of it in javaBean specification. For me it is too tedious. Then  i want
manually copy whole property from  actionOne to  actionTwo.

The second cause is process of copying. It is sometime like "magic" and copy
many objects (from action support itself.). And i want to copy just one my
property.




Ted Husted wrote:
> 
> The use case for the chain result is that JavaBean properties on
> ActionTwo that match JavaBean properties on ActionOne are copied
> forward. This sounds like the same use case that you describe, and
> it's unclear why it isn't working, or why you would need to do
> anything manually.
> 
> The most helpful thing would be to include the relevant source code
> from your Actions and struts.xml
> 
> HTH, Ted.
> http://www.catb.org/~esr/faqs/smart-questions.html
> 
> 
> On 10/10/07, Igor Vlasov <vi...@mail.ru> wrote:
>>
>> I have action "one" and it calls action "two" throw:
>>  <result  name="success" type="chain" >two</result>
>>
>>
>> I can use ChainingInterceptor to copy properties of "one" action to "two"
>> action.
>>
>> I get behaviour : one.param->two.param.
>> But the property "param" must be in  javaBeans specification(have setter
>> and
>> getter method for each property).
>>
>> Can i MANUALLY get object for "one" action or exact "one.property" from
>> :"execute()" method of action "two"?
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13136989
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> -- 
> HTH, Ted <http://www.husted.com/ted/blog/>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13149804
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Manually obtain previous action parameters after action "chaining"?

Posted by Ted Husted <hu...@apache.org>.
The use case for the chain result is that JavaBean properties on
ActionTwo that match JavaBean properties on ActionOne are copied
forward. This sounds like the same use case that you describe, and
it's unclear why it isn't working, or why you would need to do
anything manually.

The most helpful thing would be to include the relevant source code
from your Actions and struts.xml

HTH, Ted.
http://www.catb.org/~esr/faqs/smart-questions.html


On 10/10/07, Igor Vlasov <vi...@mail.ru> wrote:
>
> I have action "one" and it calls action "two" throw:
>  <result  name="success" type="chain" >two</result>
>
>
> I can use ChainingInterceptor to copy properties of "one" action to "two"
> action.
>
> I get behaviour : one.param->two.param.
> But the property "param" must be in  javaBeans specification(have setter and
> getter method for each property).
>
> Can i MANUALLY get object for "one" action or exact "one.property" from
> :"execute()" method of action "two"?
>
>
> --
> View this message in context: http://www.nabble.com/Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13136989
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
HTH, Ted <http://www.husted.com/ted/blog/>

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


Re: [S2] Manually obtain previous action parameters after action "chaining"?

Posted by Igor Vlasov <vi...@mail.ru>.
I try this in action "two".execute():

    ValueStack stack=ActionContext.getContext().getValueStack();
    CompoundRoot root = stack.getRoot();
    List list = new ArrayList(root);


This list does not contain my previous action "one". It contains only
TextProviderObject.

Can you write  how to "grab the ValueStck and traverse it up"?



-- 
View this message in context: http://www.nabble.com/-S2--Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13137399
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Manually obtain previous action parameters after action "chaining"?

Posted by cilquirm <aa...@gmail.com>.
You can, if you grab the ValueStck and traverse up it till you get to your
previous action. 



Igor Vlasov wrote:
> 
> 
> 
> I have action "one" and it calls action "two" throw:
>  <result  name="success" type="chain" >two</result>
> 
> 
> I can use ChainingInterceptor to copy properties of "one" action to "two"
> action.
> 
> I get behaviour : one.param->two.param. 
> But the property "param" must be in  javaBeans specification(have setter
> and getter method for each property).
> 
> Can i MANUALLY get object for "one" action or exact "one.property" from
> :"execute()" method of action "two"?
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Manually-obtain-previous-action-parameters-after-action-%22chaining%22--tf4601173.html#a13137301
Sent from the Struts - User mailing list archive at Nabble.com.


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