JSF, propagating event to every user - jsf

Can I propagate event to every user which currently connected to application? For example as a popup? Even if the user isn't actively using the application but only has its windows opened?
Actually requirement is to let to user know that a system is being shut down in X minutes.
Thank you.
UPDATE: as always before writing this post I hadn't any ideas, after writing this post ideas began to coming. I think about <p:poll> element from Primefaces library. It should be invoked periodically and check some flag in a session or even application scoped bean. If this flag became turned on it should run popup window. Are there any pitfalls? Is there better idea?

Related

xPages don't work after design update

Load any xPage
Refresh db design
Reload the xPage by either F5 or Ctrl+F5.
then almost all functions stop working without any errors. E.g. nothing happen if you click buttons or menu items. After restarting web browser some functions come back but some still doesn't work. After cleaning browser's cache almost 90% UI start working but some still need to reload the page few times. Is there any xPage app properties or Domino properties to adjust to fix that problem and make xPage app work smooth even after design refresh
Design Refresh didn't reload custom Java classes when refreshing with 8.5.3 FP1. This was fixed, I believe, in FP2. But that doesn't sound like it's causing the problem here.
Design Refresh will not reload jar files. That requires issuing "restart task http" to the console. ("tell http restart" doesn't properly reload everything XPages needs.)
If your application is using a Single Copy XPage Design to hold its XPages design, that too will not update until you issue "restart task http" to the server. The design seems to be cached by the server for better performance, but refreshing the design of the SCXD database doesn't reload that design. It's unclear if that's your scenario here.
XPiNC may also not update immediately, but I've not tried that. The runtime there is basically in the Notes Client itself, so I could understand that it would not update.
Otherwise, I would echo Thomas's experience, I've not seen any other issues (and my applications heavily use Java). I haven't needed to clean the application following a design refresh. Existing browser sessions will have problems with partial refresh calls, I would expect that. But a refresh of the page make all functionality work.
There are two scenarios I would expect to have problems.
The first is if you are storing anything in sessionScope or applicationScope variables that are required by your application, but your code only loads those on a specific page. If you refresh the design, the scopes will get dumped and so not reloaded until you go to the specific page. Typically I put such initialisation code on my layout custom control, so a page reload will always initialise it if it's dumped by a design refresh.
The second is if another user accesses the application and has Build Automatically switched on, which could result in the application being rebuilt without you realising it. It doesn't sound like this is happening for you though.

Struggling with Chrome Extension architecture

I'm new to Chrome extension development, and I'm a bit struggling with the architecture to put in place.
I would like to develop an extension (browser_action), that, when the button is clicked, opens a window where information will be populated from the WebTraffic.
I figured out I could use the WebRequest API to get info about the traffic.
I could create a popup window, but it's displayed only when I click on the extension button, and hides as soon as I click somewhere else
I tried creating a background window, but it does not show up.
I'd be very grateful if anyone could help me with the initial setup of my application.
Thanks in advance
You need both.
Take a look at the Architecture Overview, or maybe this question.
The lifetime of the popup is indeed equal to how long it stays on screen. It's the UI part, but putting logic there is usually bad.
A background page is permanently there but invisible. It's typically the "brain" of an extension, taking care of heavy lifting and routing messages to other parts.
In short:
You need a background script to collect webRequest information for you in some format.
You need a popup page to show it. Keep in mind it's not guaranteed to be present at a given time and can close at any time.
It's probably best to use Messaging to request the information from the background page. If you need real-time updates, you can use long-lived connections.
In your case you can also tightly couple the two and call chrome.runtime.getBackgroundPage() to directly reference stuff in it.

Single user for whole application?

In my application, JSF2.0, richfaces 3.3.3 and Tomcat.
I need, to prevent user multiple tabs in same browser.
Means, If the user login into the application, after that copying the url and paste into the other tab..that time i need to logout that user..
Help me...
Thanks inadvance.
You can and should not. You can not, because it can never be achieved reliably. JavaScript can do a lot, but you're still dependent on whether the enduser has it enabled and or the browser can successfully fire a (XML)HTTP request before the unload event, which is really a race condition. You should not, because it would completely destroy the user experience and only result in "wtf?" experiences.
You need to fix the real underlying problem for which you thought that this would be the right solution. This smells too much like session scope abuse. In that case, take your time to go through How to choose the right bean scope? You seem to really need the view scope instead.

Tracking a Chrome extension's version with Google Analytics custom variables

So I have a Chrome extension which uses Google Analytics for tracking various things. One of those things is the extension version, set using a custom variable every time the background page is started. Now my question is: Which scope should I use, visitor or session level? I can't figure it out based on Google's documentation, and no one else seems to have had this issue. I'm not even sure there's any difference, or maybe it's just something like "it's bad practice to overwrite visitor level variables".
Chrome extensions are have some very specific characteristics and the answer to this question is not applicable to anything that is not a Chrome extension.
From your question I believe you do some basic tracking on your background page, but I assume you also do so on a popup or you fire an event if the user do some action with your extension.
In that case I'll strongly suggest that you use a Visitor Level Custom var.
The problem is that the background page is loaded only once, when the browser opens up, and it's like a tab that stays open and silent, possibly hosting some callback functions for events that may or may not happen.
Because of that once the visitor first loads your extension you'll see a pageview from you background page setting this custom var.
After that there may be a silent period where your extension doesn't track anything, this period can take hours, until hopefully the user interacts with your extensions and tracks additional data to analytics. When it finally happens chances are that over half an hour has passed since the backgroun page loaded. If that is true the visit (or session) that was started by the background page is already over. A visit with no activity for 30 min is closed by analytics. In that case that interaction will spawn a new visit.
If you set the Custom Var as a visit leve variable chances are that when you see interactions on the extension, these interactions won't have the custom var.
This approach has the bad side effect that if the version of your extension changes and the user doesn't reload the browser the version is not going to be updated, and it will be erroneously registered as te old version.
That's very unlikely. And the only way to fix it is to check the version of your app everytime the user does an interaction and set that custom var again. I believe that this is excessive and I don't do it in my extension. Still if you opt for it, it really doesn't matter if it's a visit level or visitor level custom var.

Occasional weird Glassfish errors, resolved by a restart?

I'm developing a web app using netbeans with GlassFishv3.
Every once in a while when I add a new feature in my app, glassfish starts nagging with stupid errors, after a lot of time wasting and panicking, i restart glassfish and run my application again, then suddenly the errors all go away and my site starts acting correctly. (or in case I have made a real mistake, i receive a reasonable & descriptive error from GF.)
[Edit: the rest of the question was revealed to have been my own mistake.]
But the problems don't end there. Recently, i added the ability to write comments in a (JSF) page, after the user submits their comment, i add it to the database and redirect to the same page, so that hopefully the page refreshes with the new comment, but it wont!
The underlying Mysql database shows that the new comment has been added, but the page just wont show the new comment! I've tried everything (e.g. deleting browser cache, using different browsers) but only after restarting GF is when the page shows the new comment!
Do you have any idea what the problem could be? Could this be a Glassfish bug?
What i am using: JSF2, EJB3.1, JPA, MySql
Apparently the list of comments is not refreshed with new comment. Verify if the data loading logic is right. Maybe you've put it in the constructor of a session scoped bean instead of a request scoped bean. Maybe you haven't reloaded the list from DB after insertion (and commit). Instead of restarting GF, try to restart the webbrowser (close ALL tabs/instances) and reopen the page. If it works, then the old/non-reloaded data has indeed just been displayed from the session scope. If that doesn't solve the problem, then the problem is maybe more in the JPA area, debug if the new comment is actually persisted and committed and/or if the list is actually requested from the DB and not from the cache, etcetera.
thanks for the responses,
Yes, as Balus and Pascal mentioned, the problem lied in my own logic and fortunately not in Glassfish.
Incompetence was on my part, I admit and apologize;)
Indeed the problem was in the JPA area, I had forgotten to merge and refresh my JPA entity after adding the comments; so although the comments were added in the database, my JPA entities wouldn't reflect the changes.
By the way, FYI, I still have the occasional problem of my projects plain not building and/or not deploying into GF (while emitting weird error messages), which is always solved by restarting GF (more specifically, by restarting the default domain in GF);
It could probably be my mistake, or netbeans6.8's deployment bug, or in the unlikely case, GF's fault.

Resources