A way to control a web page with external link without reload - gwt

We have a GWT based thick client like web application. The application is considerably large and has some initial load time.
We would like to send the users of our application e-mail messages with href links that would open up a specific asset in our application. Well this of course has the effect that clicking the link opens up the application again, reloads it which we would like to avoid. Ideally we would like the href link to just signal our application/web page somehow so that we could pick up the event in our application and react to it.
Any ideas how we should approach this or is this even possible ?
Thanks!

You need to use a GWT Hyperlink which is a widget that serves as an "internal" hyperlink. That is, it is a link to another state of the running application. When clicked, it will create a new history frame using History.newItem(java.lang.String), but without reloading the page.
If you are not already using it, information is here on GWT's History mechanism

There seems not to be any elegant solution to send an event from a link to an existing browser window. Few solutions I have encountered this far:
a) Implement a cookie polling solution for the application to poll if a cookie exists or changes. The link points to our server which just sets the cookie and this way informs the running app about the event. Some tricky handling should be implemented with some kind of 2-way protocol between the returned temporary page from server to handle the situation where the application is not (yet) running.
b) The same approach as in solution a) but use html5 local storage for communication. This way the poller is not needed as the local storage fires an event when content changes. This would be a possible solution but is not for me as we have to support older browsers without local storage support.
c) A long polling ajax or a web socket for delivering events from the server to the client. A solution but seems overkill and might require a modern browser for atleast web sockets.

Related

How to react on session timeout in fiori apps?

i have developed a sapui5 freestyle app, running in an sap fiori launchpad. This app extends a third party solution with a fiori frontend. All is working good so far. But this third party solution uses its own locking table for its objects and i have no possibilities to change this. So when my apps is starting, it reads the data by using an odata request (the odata services are also "my" code). This odata implementation is then adding an locking entry to the third party solution. When the user "normally" ends its work on that document using save, delete or cancel, my odata implementation of the save, delete, cancel methods also deletes the lock entry in the third party solution. Even the closing of the browser or the app is handled by attaching to special browser-events, so the locks are released in that case by calling an odata method for releasing the locks.
But what if the user starts the app (which triggers the lock) and then does nothing any more. The user is running into a session timeout. And the lock-entry for document he/she was working on is still existing.
What i need is a way to react on such a session timeout with my code which then releases the lock. Maybee an event which is triggered, or maybee there is a smart idea to dealing with such session-timeouts in the backend.
Any ideas are welcome.
kind regards
Matthias

Apache Wicket: Communicate between independent pages of same application

On my wicket page I have a link that opens a second page in another tab/new window.
Click here for second window
These windows are meant to be used in parallel (e.g. in a two-monitor-environment). But I don't want to spread out different menu entries over both screens, so I want all menu entries to stay on MyFirstPage, even if they should influence MySecondPage only.
My ultimate goal is to click a menu entry on MyFirstPage that results in displaying a new Component on MySecondPage. Is this even possible? How can I obtain a java-reference of MySecondPage inside MyFirstPage or establish some other sort of communication?
Everything I found while researching only applied to modal windows or Wicket 1.4, but MySecondPage is not modal.
Maybe wicket's event bus is an option, see: http://code.google.com/p/wicket-guide/downloads/list - Chapter 15.3 Wicket events infrastructure
You could send the event in MyFirstPage , receive it in your Session or Application and there send it to MySecondPage. Session and Application implement IEventSink: http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/event/IEventSink.html
There is WebSocket support in Wicket 6:
http://wicketinaction.com/2012/07/wicket-6-native-websockets/
Basically you need to add WebSocketBehavior to the page to make it available for messages from the server.
On the other hand, you can send messages to the server via Wicket.WebSocket.send("A message sent by the client");
I have never tired it but it sounds very promising.

How to build realtime push notification feature like facebook does? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm going to build realtime push notification feature for my web application ( a small social network) and I don't know where to start.
This is what I want to build: there are like buttons, comment forms, ... Users click like, write their comments and (relatively) immediately, on the owner's browser shows the number of new likes and comments, ... Something like that.
I've read about socketIo on nodeJs, MeteorJS but unfortunately, they need WebSocket supported by mordern browsers. I've just read about Comet technic and find it pretty easy to apply. But i'm not sure it will performs well because Comet relies on long-polling connection (correct me if I'm wrong).
In addition, I think facebook is using Comet for its push notification feature. Through console tab on firebug plugin I can see there's alway a holding connection to facebook.
So can anybody show me a technic, a model to develop a feature like that?
A promising idea is to work with the HTML5 notification API; it's perfect if you want notifications to pop on the user screen as long as his browser is running (even if you're surfing another website or if all windows are closed).
http://www.paulund.co.uk/html5-notifications
However, if what you want is to update different parts of your page asynchronously (without refreshing or pushing a button), you should use together :
Ajax calls;
Listeners and observers.
When you Ajax calls retrieve particular types of json data (for example), it can trigger appearance of a badge (listener) with a number of new notifications, or so...
With JQuery installed, you should be fine...
Even though it's often not the case, sometimes, for simple tweaks, it's easier to code the job done...
You can start here :
How implement a "observer" in Jquery without plugins? (it's old, but interesting)
Or see this page :
browser instant updates with ajax/jquery
(incredible how often google queries return stacko' pages)
You should check out MQTT. It basically works on the Publish-Subscribe model and is very easy to use. This protocol has a small footprint and consumes less bandwidth. Facebook's Messenger uses MQTT too.
you can use an ajax call coming into (for example) a php script on the server, which keeps the connection open and only replies if and when something needs to be displayed to the user. should nothing happen within a certain time, the connection gets closed and the client fires a new ajax call.
note that this only addresses the client/server communication, you would still need a notification method inside the server to wake up the php script if you want to avoid having a script constantly polling the database, but there are quite a lot of soultuions to this and they depend on what language you use on the server.
I have got an idea, it is simple but it may work. Why don't you hide notification bar as Div tag and design it with css to make it look like notification bar. Then whenever some user likes or comments about the page, write php or js function and connect it to like or comment submit button that will reveal page owners invisible div to visible. And I believe , depending on what you use, I would probably prefer php session() to Identify if page owner is online and can get notifications. moreover, if you need to track statistics of the page, you may create a small database that holds, page id and user comments. You can use this database to push multiple notifications on that hidden Div. you can use Jquery to make it move like Facebook if you want to. I m not %100 percent sure if this is the most optimized way to do that but it is possible. By the way, I surfed some to see what people use to do that. surprisingly I couldn't find something as well.

Beginner GXT issues

We have a working web application, which has been developed with ExtJS for client side, and Struts, Spring, Hibernate for server side. now, we are considering to migrate to GXT (or may be GWT itself). The thing is I'm very new to GWT/GXT. and we are trying to decide whether we go down this road or not.
1) Until now, we have 2 domains for our web-app. one is that the application (Struts+...) have been deployed to, and the other is mainly a cookie-less custom CDN. The transfer between client and server is mostly XHR requests, sending/receiving JSON and/or JSONP. But with the new approach ahead of us, I began to understand that we are supposed to have only ONE domain, for the whole GXT application. Is it correct or I forgot to consider something here?
and if not, Is it possible that we deployed just part of the application (i.e. com.ourcompany.webapp.gxt.server.*) to the main server, and the contents that have been compiled and generated by the GWT compiler to the other CDN-like domain?
2) The other big issue we are facing is that the current application is consists of mostly 3 huge modules. One is responsible for "SignIn", the other is for "Webtop", and the third one is "Modules which each users has access to". The latter has been generated on the server due to "access rights" of each users, and obviously could be different from one user to the other.
The only thing I could find on this matter, which might be related is Code Splitting. Although I'm not totally sure if this would be the right solution for this.
We want that the application, on Start Up, checks whether user has been logged in or not. if not, loads the SignIn sets of javascript files (i.e webapp.signin.nocache.js), then after user has entered the correct username/password, unloads this signin file and loads webtop.nocache.js AND modules.nocache.js.
I would be really appreciated if you could help me out.
1) If your GWT app is loaded from a different domain than you have to face the same origin policy. You can not do a xhr to a different domain. You could use the ScriptTagProxy to get around this. But it does not feel very netural.
2) You can use CodeSplitting in order to automatically load a particular part of your application dynamically. All you have to do is to warp your splitt point into an async call.
A detailed compile report gives you a pretty good overview how well code splitting is working.
But CodeSplitting does not unload already loaded code. If its really importend to do so you have to redirect the user to another url in order to load the appropriate user depended module.
Once Javascript code has been loaded and executed its impossible to remove the code from the browsers memory.
Grettings,
Peter

GWT event servise browsers synchronization problem

I have implemented pretty simple application, using gwt and gwt event service 1.1.1, it sends some information to the server and waits for particular event to come back.
When application is opened in one browser window, it works fine.
When it is opened in two browser windows (the same browser and the same address: localhost:port/app or ip:port/app) on one machine, only one instance of my application receives event (UI reflects changes only in one window).
When it is opened in two different browsers, but with the same addresses (for instance, both are localhost:port/app), then both browsers receive events.
When it is opened in two windows of the same browser, but with different addresses (one is localhost:port/app, second is ip:port/app), then it also receives events.
So, could somebody provide any explanation to such behavior? And if is there some kind of workaround for this problem.
Thanks in advance,
Alex.
You are using gwt event service on the server, right?
They claim to have "Only one open connection for event listening". So they actively check that one client has only one connection for sending events. They probably use web sessions to achieve this.
Since you open the same URL in the same browses in two tabs, this two tabs share the same session. There is no way around it. There are a lot of questions about this: https://stackoverflow.com/search?q=browser+tabs+session
Update:
It seems that gwt-event-service can be configured to support multiple sessions: use SessionExtendedConnectionIdGenerator
Update 2:
Use a config file like this: http://code.google.com/p/gwteventservice/source/browse/trunk/conf/eventservice.properties?r=265