Is there any way to open a popup from a servlet
I have an asynchronous process running , and I need to somehow notify the user when finished, without having to refresh the page
any ideas ??
"Without having to refresh the page"
That's what Ajax is all about I suggest that you take a look to some Ajax enable JSF framework, like Richfaces, if you're using JSF 2.0 you can use Ajax behavior by default.
With Richfaces you can use the <a4j:poll> to check after some period of time if the asynchronous process have finished, you can then re-render the appropriate message.
<a4j:poll interval="1000" enabled="#{notificationBean.isTaskComplete}"
reRender="completeMessagePanel" />
Thats the general Idea.
Related
I am working with cometd library for pushing notifications to web page here I am facing one problem i.e., whenever I am reloading (refreshing) the browser page
ServerSession.addListener(new ServerSession.RemoveListener() {.......}
this method is calling unfortunately in some browsers how to avoid calling this listener,actually this listener should call whenever window closes or any click event occurs on link,So please help me to achieve this.Thank you
The reload extension does what you need.
With the reload extension, refreshes of the same page or click on links that move to other pages of the same CometD application will avoid that the client re-handshakes with the server, therefore keeping the original session across reloads or links.
If you want to avoid the calling ServerSession.addListener(new ServerSession.RemoveListener() {.......} while reloading the page in mozilla firefix and opera browsers just comment the $.cometd.disconnect(); and use window.onpagehide instead of window.unload because window.unload will call while refreshing the page in mozilla and opera browsers.It fit for me perfectly.Thank you.
On my MVC spring application I send a form to a page using post method to perform a search with some parameters. The results of the search is a list and, for every entry is possible to navigate to a details page. It works fine but, when an user try to come back to result page with back browser button (or a Javascript), I get an "Expire page" error. Refreshing the page, it rexecutes the post submit and it works fine.
To prevent this error I added
response.setHeader("Cache-Control", "no-cache");
to the search controller and everything works fine with Safari and Firefox but I get the same "Expire page" error when I try to execute the web application with IE (8 and 9).
What's the right way to go to a detail page and come back without getting any error?
thanks for your time!Andrea
The right way is to use GET instead of POST: searching is an idempotent operation which doesn't cause any change on the server, and such operations should be done with a GET.
Not expiring a POST request seems to undermine the very idea of a POST:
Per RFC 2616, the POST method should be used for any context in which a request is non-idempotent: that is, it causes a change in server state each time it is performed, such as submitting a comment to a blog post or voting in an online poll.
Instead, I would restructure how you view the detail records, maybe with an overlay DIV that doesn't refresh the underlying page that shows the results. With many modern web apps, using the BACK button can cause issues with page flow.
I'm using JSF 2.0, and when a form is submitted, I am generating a download. As a result of this, the submission is NOT using AJAX. When the file has been generated for download, I am calling FacesContext.getCurrentInstance().responseComplete(); to tell the browser it's done.
However, for the sake of User Experience, I want to show a "loading" message on screen when the file is being generated, then remove this message once the download has been generated. Is there a way to do this considering the lack of AJAX?
Thanks,
Chris
Edit:
I am already calling the javascript to show the message onSubmit. My problem is then calling the Javascript to remove the message when the response has completed.
Raise your loading message before submitting the form.
FacesContext.responseComplete() does not send any response to the client. It merely sets a flag in the context to tell the JSF framework that no further lifecycle phases should be processed after the current one completes.
Environment:
Spring latest
Using Spring Web flows 2
Spring MVC
Jetty server
In the situation where evoking the webflow with required parameters missing I want to print a message for the developers (I have done this by subclassing FlowController). The problem comes in when the webflow is complete and the user hits the back button. In this case I would like to redirect to another page(static).
If this were in the flow I would use a listener to perform this action, but the webflow has ended. So pressing the back button has the effect of trying to start another webflow.
Is there a way to detect the "back button" outside of the webflow?
Or any other suggestions would be helpful.
Rather than detecting the back-navigation, instead set up the last part of the webflow to not start a new flow, but instead do the redirect.
I'm using JSF 2.0 and Glassfish 3.1 and have the following problem:
I've got an application in which two users must participate. The first user should set up the session and then get to a wait page. When the second user joins, the first one should be redirected to the application page. Is this possible in JSF, and if yes, how?
Create an Ajax polling mechanism
Invoke an action from Ajax, check if condition met
If met using JavaScript code redirect the user (Or you can also make it redirect from action)