Vaadin and Liferay IPC Out of Sync error - java

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.

Related

Related to JMS Listener

Currently I am facing issues with related to JMS Listener. JMS listener is not actively picking all the messages, instead randomly selects the input messages and process it. Because of this, for few messages I could see user details being displayed, for others its not. There is inconsistency in displaying results. It is difficult to trace where the listener is actively running in the background because in my colleague's local machine, I could see listener picking messages randomly and processing it.(he does not have my code changes and so user details are not displayed). Have anyone faced this scenario? Is there any solution? I tried to push the same message (which does not show user details) from my local workspace and it is executed fine. This is to ensure my code is right or not.

GWT load fragments after application start

I am creating an app in GWT, and I just recently implemented code splitting there. I reduced the application size from 1.1MB to 570kB which is nice, so the startup time of the application is now faster (we are using special server where 500kB really matters... not important for my question though ...). After the application starts (in other words user can see login page, can login and use basic parts of the app), I would like to download the rest of the fragments.
I know the fragment will be downloaded when the code in the fragment is needed. But one of the fragments is about 300kB. So when I click in the menu of my app on an item, that causes this fragment to be downloaded, there is a very noticeable delay (1 - 2s), before the user gets a response.
Now I understand that this will most likely happen only once and then the fragment will be cached for like a year, so it will load faster next time. But for example when I try it again on another device, I will have to download fragment for the first time again.
I just need to be sure, that when user launches my app on a phone/tablet using wifi, then disconnects from the wifi or gets out of its range, he will still be able to launch the code in the fragments, even if he didn't launch the things that cause downloading them while he was still connected to the server.
Now he would have to open 3 menu items, to download all the fragments which is annoying.
So in short:
I want my initial download to stay 570kB, and download the rest of the app as soon as possible on the background (if possible).
EDIT:
I found http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html#sequence where you can setup initial loading sequence, so I guess it is what I am looking for. Not sure though if they are loaded asynchronously, because the login screen appears after the fragments are downloaded.
You can cause all fragments to be downloaded after the login panel is rendered. Simply call some method inside the rest of the code - it does not need to do something visible.
Also, if you plan to load all code this way, you only need to split one fragment - your entry point with the login panel. Each split point (a) slightly increases the overall size of the application, and (b) increases, sometimes significantly, the size of the leftover fragment which still needs to be loaded for the first fragment to show up. Thus, there is no point in having more than the initial fragment and the rest of the app, given your requirements.

How to make a webpage reload automatically when another session of the same website has done some work parallely?

I'm working with a project of patient queuing using JSP and Eclipse IDE. In it, I require a message to be conveyed between two different sessions of same website (i.e. the doctor's and compounder's homepage are alive).
As soon as the doctor finishes consulting a patient, a message is to be passed to the compounder's home page saying "To send new patient in".
I checked session creations and MVVM. But it doesn't satisfy me. Will anyone please help me out on this? I have tried an "auto refresh" inside JavaScript, but I ended up in an infinite loop.
This is a very broad topic. You can go about it in several ways and using several technologies (message queues/brokers, websocket, dwr, etc).
This is similar to building a chat application so maybe search for that online (again another broad topic).
If you want something very simple (and most of the times inefficient - but that depends on your requirements) you can go about it this way:
Have a simple database behind your application (an application wide thread-safe queue should work too but a database gives you persistance in case something happens to the application, like a server crash);
once the doctor finishes the consultation, his page saves an entry to the database, a flag basically;
The compounder's page has an Ajax request that from time to time (say 10 sec) looks for the flag in the database;
if the flag is found it displays a message on the compounder's page to send the next patient and then resets the flag
repeat step 2.
Those are broad steps to build something simple. As I said, not the most efficient way. Search for how to build a chat and you'll find better ways since a requirement for chat applications is to be fast and scalable.

Listener for when the user changes window (not necessarily windows created by the application)

I need to add a functionality in my application that would require me to know when the user changes window (it could be a browser window, my application's window or any other window).
Ideally, it should be possible for me to print the window's title when it gets focus. The problem I'm having finding a solution to this problem is that I only get links that tell me how to add a focus listener on windows I'm creating, which I already know how to do and doesn't help me in the slightest.
The solution should at least work on Windows 7.
The (major) problem you face is that Java filters system events so that you can only recieve events that are related to you. AFAIK this is all done at a native level, so there's no way to intercept or modify this filtering process.
The only solution is to create another "event loop" using JNI/JNA which will allow you to intercept the event messages being passed about the system and handle them the way you want to.
While slightly more complicated, it does open up a world of opportunities...

Alternative to clipboard for sharing data between a web based application and legacy desktop application

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,

Categories

Resources