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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]