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.
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've been pondering over this problem most the afternoon and haven't yet found the most ideal solution so thought I would see what others think..
There is a legacy Win16 application that has to be modified (with the least effort) in order to communicate with a web based application.
The idea is such that in the Win16 app, the user will want to look up a specific code, so they'll click a button which will then launch the browser and allow them to navigate a specific set of pages until they find the result they desire, then they have the option of either pressing Select or Cancel.
Pressing Select should pass back a small string back to the app (around 10 characters) and close the browser. Cancel will likewise send a Cancel message back to the app and again close the browser window.
I can't see many choices available in implementation as the Win16 app is not able to call webservices, so I'm looking at using the clipboard, however that is not without problems.
I hope there's some other alternative I haven't thought of,
As always - all advice appreciated.
Thanks,
I know this is almost the same question: ask by Joe
I have a web application. When I close the window (clicking X on browser) it will call the Logout functionality.
The problem is when I open the web application and open the same web application on different window (new window or another tab). And close one of the window it will call the Logout functionality even if there is still an open window for that application.
What I want to do is, check first if there are other window that is using the same jsessionid with the current window I am about to close. And when I close that window, It will only call the Logout functionality if there is no window using the same jsessionid.
The standard way of course would be to have the login cookie expire at browser close and thereby log you out, but I'm guessing this is not an acceptable behaviour in your case?
AFAIK you can't access the content of another browser window unless that window was created using Javascript. Since it sounds like you're using onUnload handlers in Javascript, you could make use of those same handlers to keep track of your windows. It would lead to some overhead though and would not be full-proof (would not handle browser crashes or if the user navigates away from your app for example).
Pseudo-code: (this needs to be a mix of server-side code and client-side javascript since the load handlers are handled in Javascript and the session is server-side)
function OnLoad() {
if (document.referrer != "{identify your app here}")
Session("BrowserWindowsOpen")++;
}
function OnUnLoad() {
if ({your code for if window is closed})
{
Session("BrowserWindowsOpen")--;
if (Session("BrowserWindowsOpen") == 0 )
performLogOut();
}
}
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.
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.