Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Status Message display to user side for long running method in jsf

 
Karthikayan Rajasekaran
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using jsf 1.2 with icefaces 1.8.

My doubt is I have a command button called process. Whenever i clicked this button process method is called. The process method execution takes nearly 10 minutes.

I want to display the status message to user side.

I have tried like this.

<ice:commandButton value="process" action="#{bean.process}" immediate="true"/>

<iceutputText value="#{bean.statusMsg}" ></iceutputText>


public void process()
{
public void start();
public void stop();
public void restart();
}



public void start()
{
setStatusMsg("Started");
...........
...........
}

public void stop()
{
setStatusMsg("Started");
.............
}

public void restart()
{
setStatusMsg("ReStarted");
....................................
}

Here problem is last method status only printed in user side.(restarted).


How to print the status of each method in icefaces1.8 or jsf 1.2?

Please help me , very urgent.............

Thanks,
Karthikayan.R
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18025
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Karthikayan!

You cannot do that in JSF, general J2EE, or, for that matter, in any web platform in any programming language.

HTTP is a strict request/response protocol. One request gets one response. Therefore you cannot make a request, get a "busy" response back, followed by a "done" response. You get only one response and that response isn't posted out until request processing is complete.

For a long-running process, you will need to offload the long-running part to a separate thread. Note that you cannot spawn this thread from within JSF or servlet/JSP code - that is explicitly forbidden by the J2EE standards (and will possibly crash your appserver). You can, however, construct an out-of-band "engine" process in a webapp servletcontextlistener and post your long-running requests to it. The JSF code would then be in charge of sending the request to the engine, polling the engine status (you can use AJAX for this), and returning the completed results once the engine has finished the request.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic