How to reload the web page in GWT? I want to reload the page after a user logged in the system and then it will show the personal status on top of the page. Any idea how?
Thanks a lot.
Window.Location.reload() will reload the page, but I'm pretty sure reloading the page is not what really you want.
You probably just want to refresh certain parts of the page to update once the user logs in.
The reason is, reloading the page will re-download the JavaScript and images on the page, which is a lot of traffic just to refresh the UI.
For problems like these, you could use an event bus... seems very well suited to what you want to do. Your authentication widget could raise an authentication event on the bus, and all widgets on the page that ought to be reacting to this can just pick it up and change themselves.
There's a discussion about it here.
I suggest creating a div specifically for this display area in your HTML page.
For example, in your HTML file:
<div id="header"></div>
<div id="userStats"></div>
<div id="content"></div>
... the rest of our page
However you are catching when someone logged in (Database, EventBus, whatever), just update that single panel like so:
RootPanel statsPanel = RootPanel.get("userStats");
statsPanel.clear();
statsPanel.add(new StatsPanel());
Perhaps you create your StatsPanel using the UiBinder.
Related
I am using Fancybox 2 for my web application. I read its online documenation, but failed to find a way of opening iframe without showing it to a user.
The reason for my inquiry is that when a regular page is loaded, I would like to make a Fancybox iframe get loaded too without a user's notice. When the user clicks on a link on the page that will trigger Fancybox to show the iframe, I would like to make it simply visible. I hope this would greatly improve user experience in terms of speed.
Any ideas or links would be really appreciated.
You could, for example, simply create hidden iframe element and display it as any other "inline" element using fancyBox.
I've got an A/B Test set up in Adobe Test-and-Target. The idea is that 50% of the time, visitors to a certain page should be redirected to a different page instead. It is working correctly, in that half of users are sent to the new page.
However, sometimes the entire original page is loaded before the redirect happens. I put the mbox in the head tag of the page, which I thought would ensure the redirect happened before any HTML was displayed to the user, but that's not happening.
How can I create a seamless result for the user, where the redirected users only see the new page loading, and never see the original page?
For our site, the <script src="http://maur.imageg.net/js/mbox.js" ></script>is at the very end of the head tag and works fine.
Your mbox.js should be as close to the top as possible and then your inline mbox should be defined preferably right after the tag. This way the request is made before the content starts to render, and the redirect kicks in before the guest even sees the page.
Avoid using anything post DOM related for example jQuery's:
document.ready( function{});
If you paste your code you're using for the A/B - we be able to review & respond accordingly.
However pure Javascript and pure CSS should execute seamlessly.
You can use CSS first to not show anything
<style>
body {display:none!important}
</style>
Then use JavaScript to redirect the page to new page.
I'm using a simple (Meta) timed redirect on a web page. The viewer may wait the allotted time or click on a link to leave the page. I would like to block the viewer's ability to return to the original page after leaving it.
I've been cautioned about using Meta scripts due to the possibility of search engine rejection- true or not, I haven't a clue.
If possible, I would like to avoid Java or the use of cookies. Nonetheless, if Java is the best or only solution, I am open to it.
Your thoughts and guidance are greatly appreciated.
Thanks.
You can try something like this:
<script>
function preventBack(){window.history.forward();}
setTimeout("preventBack()", 0);
window.onunload=function(){null};
</script>
You can place that code on the page that you don't want the user accessing using the back button in the head section. But, it is not recommended since it might annoy your users.
This post explains things in a bit more detail from multiple users.
I'm trying to add a link to allow a user to refresh the Comments plugin on my page so they can see other posts by other people.
I want to do it without refreshing the full page.
There's a html5 player on the page playing audio, hence me not wanting to interrupt that player.
Currently I'm using the standard -
I've tried the jQuery method of giving the div an id and having a header script which counts to 10 and reloads the div widget, it seems to reload the widget, but it doesn't update the contents of the comments plugin to show other's posts, just ones you've added yourself. To see all the updates you have to refresh the page fully, which I don't want to do.
I'm trying to avoid iFrames because of the height issues and extra scroll bars, etc.
Any ideas would be appreciated
I'm not exactly sure what you're trying to do, but you can use the FB.XFBML.parse method to refresh plugins.
The only thing is that you'll need to first remove the old plugin from the dom, then add the new html5/xfbml placeholders (what you get from the comments plugin page when clicking "get code") and then use the FB.XFBML.parse method.
I have a form that looks like this
<form action="/receiver.pl" method="post">
</form>
Clicking on the submit button doesn't take the user to a new page, because of some JQuery that can be seen here.
Is it possible in receiver.pl to reload the current page?
What receiver.pl is doing is processing some data that is shown on the current page, where the submit button is.
So it would be really cool if the page could be reloaded, so the changes could be seen right away.
Receiver wouldn't do that. What you'd do is this:
jQuery makes an AJAX call to receiver.pl
Receiver.pl does its thing and returns a valid JSON string to jQuery.
jQuery then reloads the page or alters the page based on the content of the JSON results.
The CGI itself cannot reload a page once it's already been loaded.
No. A server side process can only return data to the client. The client has to initiate reloading the page. This would normally happen when the form was submitted, but the JavaScript is intercepting that action and replacing it.
It sounds like the solution is "Remove the JavaScript that is stopping normal form submission".