Asynchronous Display of Action Results

2011-07-11 Thread Baubak Gandomi
Hello,

 

I am not able to find any mention of this topic, or even if it is really
Struts 2-related.

 

I have a view which calls two actions using 



/WEB-INF/pages/main.jsp



 



/WEB-INF/pages/page1.jsp







/WEB-INF/pages/page2.jsp







 

 

---action_tld.Main_Class

public class Main_Class {

  private int delay = 0;

 

  public String method1() {

setDelay(5000);

sleeper();

return ActionSupport.SUCCESS;

  }

  

  public String method2() {

setDelay(500);

sleeper();

return ActionSupport.SUCCESS;

  }

  

 

---main.jsp



waiting..



  










 

  



 

---Page1 & 2

Just show a simple text

 

In the example above method2 takes longer to execute than method1. Today
when I execute start The result of action1 is displayed before action2.
However what I want is that action1 & action2 to be executed
simultaneously, and that the result of action2 is presented first.

 

This may not be a Struts2 question perse, but if anyone has any leads I
am much obliged. 

 

Best regards,

 

Baubak



Re: Asynchronous Display of Action Results

2011-07-11 Thread Wes Wannemacher
You can achieve the outcome you desire by using AJAX instead of the
s:action tag. Here is an (untested) jquery example -



");
$("remoteAction2").load("");
});


I'm too lazy at the moment to make sure that the javascript is
correct, so if someone notices any glaring errors, please chime in.

-Wes

On Mon, Jul 11, 2011 at 10:43 AM, Baubak Gandomi
 wrote:
> Hello,
>
>
>
> I am not able to find any mention of this topic, or even if it is really
> Struts 2-related.
>
>
>
> I have a view which calls two actions using  are called in the domain of the actions take different times to execute.
> I would like my actions to be run parallel. I.e. Once they are finished
> executing, that their results are show the moment they finish.
>
>
>
> ---Struts.xml
>
> 
>
>        
>
>            /WEB-INF/pages/main.jsp
>
>        
>
>
>
>         method="method1">
>
>            /WEB-INF/pages/page1.jsp
>
>        
>
>
>
>         method="method2">
>
>            /WEB-INF/pages/page2.jsp
>
>        
>
>
>
>    
>
>
>
>
>
> ---action_tld.Main_Class
>
> public class Main_Class {
>
>      private int delay = 0;
>
>
>
>      public String method1() {
>
>            setDelay(5000);
>
>            sleeper();
>
>            return ActionSupport.SUCCESS;
>
>      }
>
>
>
>      public String method2() {
>
>            setDelay(500);
>
>            sleeper();
>
>            return ActionSupport.SUCCESS;
>
>      }
>
>
>
>
>
> ---main.jsp
>
> 
>
> waiting..
>
> 
>
>      
>
>
>
> 
>
>            
> 
>
>
>
>             executeResult="true"> 
>
>      
>
> 
>
>
>
> ---Page1 & 2
>
> Just show a simple text
>
>
>
> In the example above method2 takes longer to execute than method1. Today
> when I execute start The result of action1 is displayed before action2.
> However what I want is that action1 & action2 to be executed
> simultaneously, and that the result of action2 is presented first.
>
>
>
> This may not be a Struts2 question perse, but if anyone has any leads I
> am much obliged.
>
>
>
> Best regards,
>
>
>
> Baubak
>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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



RE: Asynchronous Display of Action Results

2011-07-11 Thread Baubak Gandomi
Thanks I'll test your solution, and see how it works.

-Original Message-
From: Wes Wannemacher [mailto:w...@wantii.com] 
Sent: lundi 11 juillet 2011 16:52
To: Struts Users Mailing List
Subject: Re: Asynchronous Display of Action Results

You can achieve the outcome you desire by using AJAX instead of the
s:action tag. Here is an (untested) jquery example -



");
$("remoteAction2").load("");
});


I'm too lazy at the moment to make sure that the javascript is
correct, so if someone notices any glaring errors, please chime in.

-Wes

On Mon, Jul 11, 2011 at 10:43 AM, Baubak Gandomi
 wrote:
> Hello,
>
>
>
> I am not able to find any mention of this topic, or even if it is really
> Struts 2-related.
>
>
>
> I have a view which calls two actions using  are called in the domain of the actions take different times to execute.
> I would like my actions to be run parallel. I.e. Once they are finished
> executing, that their results are show the moment they finish.
>
>
>
> ---Struts.xml
>
> 
>
>        
>
>            /WEB-INF/pages/main.jsp
>
>        
>
>
>
>         method="method1">
>
>            /WEB-INF/pages/page1.jsp
>
>        
>
>
>
>         method="method2">
>
>            /WEB-INF/pages/page2.jsp
>
>        
>
>
>
>    
>
>
>
>
>
> ---action_tld.Main_Class
>
> public class Main_Class {
>
>      private int delay = 0;
>
>
>
>      public String method1() {
>
>            setDelay(5000);
>
>            sleeper();
>
>            return ActionSupport.SUCCESS;
>
>      }
>
>
>
>      public String method2() {
>
>            setDelay(500);
>
>            sleeper();
>
>            return ActionSupport.SUCCESS;
>
>      }
>
>
>
>
>
> ---main.jsp
>
> 
>
> waiting..
>
> 
>
>      
>
>
>
> 
>
>            
> 
>
>
>
>             executeResult="true"> 
>
>      
>
> 
>
>
>
> ---Page1 & 2
>
> Just show a simple text
>
>
>
> In the example above method2 takes longer to execute than method1. Today
> when I execute start The result of action1 is displayed before action2.
> However what I want is that action1 & action2 to be executed
> simultaneously, and that the result of action2 is presented first.
>
>
>
> This may not be a Struts2 question perse, but if anyone has any leads I
> am much obliged.
>
>
>
> Best regards,
>
>
>
> Baubak
>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

-
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



Re: Asynchronous Display of Action Results

2011-07-11 Thread Dave Newton
On Mon, Jul 11, 2011 at 4:51 PM, Baubak Gandomi wrote:
> Thanks I'll test your solution, and see how it works.

It's the only solution there is.

Dave

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



RE: Asynchronous Display of Action Results

2011-07-11 Thread Baubak Gandomi
Thanks Wes,


$(document).ready(function() {
$("#remoteAction1").load('<s:url action="action1" />');
$("#remoteAction2").load('<s:url action="action2" />');
});


After figuring out how to work with jquery it all worked like a charm. Thanks 
for your help.

Best regards

Baubak

-Original Message-
From: Wes Wannemacher [mailto:w...@wantii.com] 
Sent: lundi 11 juillet 2011 16:52
To: Struts Users Mailing List
Subject: Re: Asynchronous Display of Action Results

You can achieve the outcome you desire by using AJAX instead of the
s:action tag. Here is an (untested) jquery example -



");
$("remoteAction2").load("");
});


I'm too lazy at the moment to make sure that the javascript is
correct, so if someone notices any glaring errors, please chime in.

-Wes

On Mon, Jul 11, 2011 at 10:43 AM, Baubak Gandomi
 wrote:
> Hello,
>
>
>
> I am not able to find any mention of this topic, or even if it is really
> Struts 2-related.
>
>
>
> I have a view which calls two actions using  are called in the domain of the actions take different times to execute.
> I would like my actions to be run parallel. I.e. Once they are finished
> executing, that their results are show the moment they finish.
>
>
>
> ---Struts.xml
>
> 
>
>        
>
>            /WEB-INF/pages/main.jsp
>
>        
>
>
>
>         method="method1">
>
>            /WEB-INF/pages/page1.jsp
>
>        
>
>
>
>         method="method2">
>
>            /WEB-INF/pages/page2.jsp
>
>        
>
>
>
>    
>
>
>
>
>
> ---action_tld.Main_Class
>
> public class Main_Class {
>
>      private int delay = 0;
>
>
>
>      public String method1() {
>
>            setDelay(5000);
>
>            sleeper();
>
>            return ActionSupport.SUCCESS;
>
>      }
>
>
>
>      public String method2() {
>
>            setDelay(500);
>
>            sleeper();
>
>            return ActionSupport.SUCCESS;
>
>      }
>
>
>
>
>
> ---main.jsp
>
> 
>
> waiting..
>
> 
>
>      
>
>
>
> 
>
>            
> 
>
>
>
>             executeResult="true"> 
>
>      
>
> 
>
>
>
> ---Page1 & 2
>
> Just show a simple text
>
>
>
> In the example above method2 takes longer to execute than method1. Today
> when I execute start The result of action1 is displayed before action2.
> However what I want is that action1 & action2 to be executed
> simultaneously, and that the result of action2 is presented first.
>
>
>
> This may not be a Struts2 question perse, but if anyone has any leads I
> am much obliged.
>
>
>
> Best regards,
>
>
>
> Baubak
>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

-
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