Detecting when GWT uses a fallback user.agent property? - gwt

There's a number of threads I've found on GWT's handling when it can't find a permutation for a browser i.e. returning of "unknown" which then becomes an attempt to GET a resource named /undefined.cache.js
I've also read and understood how you can use fallback properties to workaround this by setting a fallback user.agent property when no browser permutation is found (suggestions are 'safari' or 'gecko1_8').
What I can't find is a way to detect that the user.agent string has been set from a fallback property so we can popup a message to warn the user they are on an unsupported browser and the UI may not functional fully. In a couple of threads there are vague references to using deferred binding. I'm not an expert in that, although I understand the basic concept, and I can't quite see how that helps - how would deferred binding tell the difference between a user.agent which is actually a 'safari' compatible browser, and hence supported, vs the fact that 'safari' was chosen as fallback for an unsupported browser. Without that, I can't see a way to warn the user.
Hopefully I'm missing something here - at present, I'm on the verge of the much more brittle approach of altering our server to return an HTML error page for that undefined.cache.js resource fetch.

Use UserAgent and compare the runtime vs compile time values. The compile time value does not take into account the fallback value.

Related

How to disable wss4j timestamp cache

I need to update a javaEE application (still in java 1.7) that provides a SOAP web service. And I'd like to disable the TIMESTAMP_CACHE that wss4j (v2.0.2) uses to control reply attacks. It creates too many files and the OS reaches the maximum open files allowed, repeatedly. The files start to appear, one for each request that has been made and are named in the following way:
wss4j%002etimestamp%002ecache-e%0058ga%0058l%0058%004b%0057g%004ah%0050w==.data
The documentation states that the TIMESTAMP_CACHE can be changed (or so I understand):
ConfigurationConstants.ENABLE_TIMESTAMP_CACHE ("enableTimestampCache"): Whether to cache Timestamp Created Strings (these are only cached in conjunction with a message Signature). The default value is "true".
I've found many examples to change some of these ConfigurationConstants when a client application creates the Call object. See an example to change the PASSWORD_TYPE constant:
Service service = new Service();
Call call = (Call) service.createCall();
...
call.setProperty(UsernameToken.PASSWORD_TYPE, WSConstants.PASSWORD_TEXT);
call.setProperty(WSHandlerConstants.USER,"werner");
However, my application is not on the client side but on the server side and I haven't found so far the way to change the ENABLE_TIMESTAMP_CACHE constant.
Any idea?
I couldn't find a way to disable the timestamp cache. However, the wss4j behaviour described above happened to be a bug that not only resulted in lots of open files but in lots of open threads. It has already been fixed in version 2.0.9. Upgrading to the "newer" version did the trick.
You can find here the discussion in full that drove to the bug discovery and here the fix in wss4j's jira

What should I use for i18n in Flutter: S.of(context) or S.current?

I'm using the i18n plugin for Flutter (I believe it's this one) that comes with Android Studio.
And in every example I see it says to use S.of(context).my_string to get the Strings but it always returns null.
If I use S.current.my_string, it seems to work.
So is S.current the right way to do it and every doc/tutorial out there is wrong, are they the same or what?
What I'm basically asking here, is what is the difference between them.
Seems like S.of(context) is initially available way to access localised string.
But sometimes you need to use it without Build Context (in ViewModel, for example). So S.current was added for these cases.
More info here

How to remove id location strategy from Selenium IDE

the problem is: my web application uses ZK, which automatically generates random UUID for each web element.
When I try to record some basic test-case with Selenium IDE, it automatically tries to use these randomly-generated ID's, without even giving me a good alternative.
Is there a way to forbid Selenium IDE to use IDs while locating elements?
Possible workaraounds:
Implement ID generator in ZK: I've thrown away this possibility, because the application GUI is too complex for this task, and ID should be unique for whole sesion, which make this workaraound really hard to implement, when you have same elements on different page.
Find another recording tool: I've only found XLT script developer, which does the work by writing DOM-path using classes (which zk gives plenty) - but sometimes the location strategy gives false path, which is then not reproducible. Any good alternatives here?
You can change locater builder by changing the order of the locater in options>locater builder.
For example if you want to give first preference to css: name drag it on the top so when you start recording it will first give the preference to css name
Hope this will help you

In GWT, which javascript function run when you click on a button?

GWT auto generate the JavaScript code.
I could not understand the generated code event mechanism.
for instance, which function run when I click on a button?
I would love to see the javascript that GWT generates for button with explanations
For event handling, GWT attaches a EventListener (generally, your widget) as an expando property (called __listener) of the elements. The events are then all handled by a single dispatch method that looks at the __listener expando of the event's target and dispatches the event to it. Of course, the dispatch method does a bit more (event previewing, entry/finally scheduled commands, etc.)
This dance is (or at least was) required to avoid memory leaks in browsers (mainly IE). You can find more details in the GWT wiki: https://code.google.com/p/google-web-toolkit/wiki/DomEventsAndMemoryLeaks
When you develop in GWT, you don't care about JavaScript.
You should look at the Java code, and search for a function that handles the click event for your button.
When you compile the code Compiler will generate the autoamted Javascript functions ...And that too in compressed (thats depends on your compile type).
It is very hard to find the corresponding function and widget id because those are generated by compiler ..So its better to debug your gwt code is hosted mode ..
Even you want to read the generated code while compiling give the compilation type to
DETAILED, which improves on PRETTY with even more detail (such as very verbose variable names)
Still more details available here .
You should use GWT Compiler options STYLE whenever you need to understand the GWT's output js. GWT by default compresses and obfuscates the javascript output as it uses OBF as default value for STYLE.
To prevent compression and obfuscation you can use PRETTY or DETAILED as the parameter to STYLE argument.
NOTE: You should always use OBF mode for production as it ensures smallest bandwidth usage along with obfuscation.
Reference - https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#DevGuideCompilerOptions

NPAPI: preferred windowing model (windowed/windowless/xembed) for non-visual plugin

I'm creating an NPAPI plugin that isn't supposed to have a UI (for use from Javascript only). What windowing model should I use (windowed/windowless/xembed) to support as many browsers (and browser versions) as possible?
I currently implement the following functions:
NPP_SetWindow: do nothing, return NPERR_NO_ERROR
NPP_Event: do nothing, return kNPEventNotHandled (0)
NPP_SetValue: do nothing, return NPERR_NO_ERROR
NPP_GetValue: if asked for NPPVpluginNeedsXEmbed, answer yes if the browser supports it (NPNVSupportsXEmbedBool), no otherwise
For this plugin I am supporting Linux & Windows only for now. The NPPVpluginNeedsXEmbed was necessary for Chrome on Linux (bug 38229), however some old versions may not support it as the MDC page says that the sample plugin for XEmbed is only supported on Firefox 2.0+.
The most common that I have seen is to not care at all about the windowing mode and set the object tag to 1x1 (you can try 0x0, but I've seen browser bugs related to that) size, in which case it doesn't really matter what window mode you use. However, I would do windowless myself since it won't ever cause the trademark block that floats over all other DOM elements that a normal windowed (XEmbed or not) plugin gives you.
This is what FireBreath does if the FB_GUI_DISABLED flag is set.