I was curious how FB http://www.facebook.com/ makes the chat window intact (fixed where it is ) even if you click any link on that page behind the chat. The URL changes, page's content get changed but the Chat window remains intact. Can you put some light how can I implement that feature?
The key is that it's not using postback. There's only ever one 'page' loaded, but content, layout, URL and the like are all being updated client side via AJAX requests. It remains one persistent page as far as the browser is concerned. emusic.com recently implemented a site in a similar vein.
Related
Is it normal that the default place is automatically in the browser history at the first position? When I initially call my application I have the possibility to use the back button in my browser. Then the browser jumps to my default page which is my error page. Is this the normal behavior?
The history is handled by the browser. You have no chance to change it.
Maybe you can change your application and use a dialogbox to show your errors, so no entry will be down in the browser history.
Read the gwt documentation about history.
http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsHistory.html
Look at:
History.addValueChangeHandler(new ValueChangeHandler.....
Then you need to set history tokens in each view.
With this you can change the browser back button behaviour and how you navigate in the app.
I'm using 2 Vaadin Portlets on the same page in Liferay. The first one shows a Table of entries and each row has a button to show details about this entry.
When the button is clicked an IPC event is send which is received by the second portlet, which then switches also to a table view showing the content.
By clicking a close button on the first portlet, the second one will receive again an IPC Event and go back to its original state, which is a blank view that has only the Liferay IPC listener attached to it.
My problem is that after the third click I get an out-of-sync error by Liferay. When the view is changed I always attach it to the main window. So I don't create additional windows that have the same name.
When I use only one portlet on the page I can switch back and forth without any problem. Could it be that the at some point the browser want to fire an event on the client side, but the IPC is already gone on the server side ?
Its really hard to determine the root of this problem.
You are on the right track. IPC works on client side and out-of-sync is caused by non existing component being called from the client to the server.
There might be a few thins causing this, but some scenarios to check:
You say you have a close button that clears the display. Calling Application.close() maybe? This actually might cause a new (server-side) application instance to created and called instead of the original.
You might be creating a new instance of the IPC component, but the old one is still registered and tries to send something (to its non-existing server part).
JavaScript timing issues could cause the IPC events to be sent in different order that you might expect. I see this unlikely if it the behavior is always consistent, but still a possibility.
Hope this helps you to narrow down the case a bit and find a solution. Keep this question updated.
I am truly struggling with this - i have checked all of the other Stack overflow pages and while this may seem like a duplicate question there are NO other answers I can find anywhere besides potentially using multiple modules (even though this does not seem correct)
All i want to do is have a set of static pages making up a website for my main page, the Login page (i plan to use RequestFactory to pull back the user permissions to display stuff for the app from here - somebody suggested in another post such as this to do it from a "Non-GWT" page - that doesn't sound correct to me), and then when the user logs in successfully he gets directed to the actual app with certain things being displayed based on his current permissions.
Now, i have implemented little test projects with multiple JSPs to do redirects using Window.Location.replace("...") but then I have no idea how to actually populate that particular page with what I want to be replaced.
From just 1 GWT app is it possible to have a full web page in static HTML files (or even JSPs i don't care), a Login Page, and the actual App.
And if this is so, How do you do this?
I use RootLayoutPanel.get() to load up my main App - how does it know which RootLayoutPanel to actually use - i've spent hours fighting with this and a lot of the tutorials / answers to the questions don't provide much depth as to how to actually go about implementing anything. There is obviously something i'm just missing
I want to do something exactly like the example in the showcase: https://www.blueworkslive.com/#!gettingStarted:overview
If you use chrome and check the tags every single page on there says GWT 2.4, so it's definitely not like one answer i came across saying "don't use GWT for the login". This seems like it should be something simple that I just... am not finding or honestly am not getting from any of the examples.
This is close to the last step of my project and any help on this would be greatly appreciated.
I'm using Apache Shiro with GAE, Objectify for a database and RequestFactory - there is only one main html page and the app is simply calling getRootLayoutPanel to load the app. not sure if any of that is useful.
implementing the page isn't the issue it's just the redirecting
To login on GAE, via Google account or federated login, you need to redirect your user to login page. Since you run GWT, which usually only has one page, you have two choices:
Do the normal redirect to login page - in this case browser will go to login page and you will loose GWT app state. After login, you can be redirected back to GWT app. As said - GWT app state will be lost. This is the simple way.
Open the login page in child window or iframe. Set destination URL to a page that closes the window (actually it must install a javascript parent hook, that destination page calls). When login is done, destination page calls JS hook, which notifies parent page thet login procedure is over, closes the child window/iframe and continues. This is more complex, some login pages do not like iframes (in case of OpenID login), but it retains your GWT app state.
To answer your question:
Yes it's possible to have multiple pages in a GWT project (GWT pages/modules and static files). Of course, as you navigate from page to page, you will loose app state. GWT module is only "active" as long as page is loaded in browser.
I noticed that if you're playing a song at http://listen.grooveshark.com/ and you hit the back button Flash is smart enough to keep on playing the music while navigating "back" inside the Flash application.
Is it possible to implement this sort of thing using Java Applets, or do Applets alway shut down when you navigate away from the page (even though the resulting page contains the same applet)?
Looks like grooveshark is being tricky with the URL fragment. They store the search after the # fragment delimiter in the URL, e.g. do a search for ween, and you get this URL
http://listen.grooveshark.com/#/search/songs/?query=ween
Then do a search for bungle and the URL changes to
http://listen.grooveshark.com/#/search/songs/?query=bungle
If you click the back button in your browser, the URL changes to the previous "ween" one, but the browser remains on the same page, because everything before the fragment identifier is the same. There's some javascript that's detecting the changed fragment and updating the UI accordingly.
You could probably do something like this with an applet, but it seems better suited to javascript. The good news is, your applet is going to be cached by the browser, so if you do switch to a different page the applet loading will happen quickly.
http://java.sun.com/docs/books/tutorial/deployment/applet/lifeCycle.html
When the user leaves the page, for
example, to go to another page, the
browser stops and destroys the applet.
The state of the applet is not
preserved. When the user returns to
the page, the browser intializes and
starts a new instance of the applet.
That being said, what you could do is save the state to the server when the applet is stopped and then restore the state from the server when it starts again. If you make it a signed applet it should be able to save the state locally.
Hi I am building div content with AJAX call, but when I make call to any page from loaded page, if there is any exception the content loaded from AJAX call is not there in previous page. Is there any way to stop happening that?
Ajax vs Back button
If I understand well you are pressing the browser back button.
If you don't manage the history of the browser, it will break Ajax. The browser simply goes to the last location loaded, no ajax involved. If you did 3 ajax calls/loads in the last page, back button will ignore this because it's just javascript in the page and it will go back... very back.
What you can do
There are things you can do to preserve the back semantics in your ajax app but I don't know how you do it with jquery. Maybe it has tools for that. I know something about GWT that has history managing. But it's another framework...
See the History plugin. Highly recommended for this purpose.