GWT: What user.agent is my browser using? - gwt

I am using GWT 2.5 and GWT 2.7. I suspect that am running into a bug caused by GWT selecting the wrong user.agent property. How can I see what user.agent property GWT has selected?
Ideally, I would like be able to open my browsers developer tools and enter something like window.gwtProperties.getUserAgent. This would return one of the values that I have specifide in the user.agent my something.gwt.xml file.
Starting point: I know in GWT 2.5 the user agent is selected by UserAgentPropertyGenerator. This writes a javascript function to somewhere that is executed and determines what user.agent is used.
Thanks.

The xsiframe linker (used by default in 2.7) will output a compilation-mappings.txt file mapping each permutation strong name (equivalent o a generated *.cache.js file) to the permutation property values. So looking at which file has been loaded by your browser, you can easily track back which user.agent was computed and used.

Related

Jasper quits PDF generation with Error while loading available fonts

On my local jBoss machine, generation of PDFs works fine. However, when I try publish (so far it seems so) basically anything on NetWeaver deployed same code of application, generation crashes with this error:
08-06-18:00:46:45 [HTTP Worker [#802492534]] ERROR [JRStyledTextParser:paveljanicek] Error while loading available fonts
net.sf.jasperreports.engine.JRRuntimeException: javax.xml.parsers.ParserConfigurationException
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.<init>(SimpleFontExtensionHelper.java:156)
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.getInstance(SimpleFontExtensionHelper.java:131)
at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.ensureFontExtensions(FontExtensionsRegistry.java:80)
at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:57)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:130)
at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:86)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:111)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:69)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:219)
at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:234)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:134)
Worst part is, I cannot think about how to reproduce this error. This is what I already checked on target machine:
Fonts are installed and accessible to the app
jasperreports-fonts.jar is accessible to the Jasper reports
On my local machine:
PDF does generate with warnings (I am using old attributes like issplitAllowed or border)
If fonts are deleted, local instance crashes with different error (mostly "Fonts are not available to the JVM")
Does anyone has any idea what to check, where to look?
NW uses default XML parser, which doesn't support setting security feature "http://apache.org/xml/features/disallow-doctype-decl". This feature is set by Jasper style sheet parser from version 6.4.2
Quick solution is to use different XML parser, which supports mentioned feature by setting system property "javax.xml.parsers.DocumentBuilderFactory" to proper XML parser in NW properties.
Definitely the issue is on NW side.
However, I did find an Oracle equivalent XML parser (still based on Xerces) that is more forgiving when setting XML features: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.
This parser comes with the Oracle JVM used in the project so we do not need to add an additional library and is actually the default parser based on JavaDocs.
Netweaver JVM decided to use oracle.xml.jaxp.JXDocumentBuilderFactory as default instead.

Detecting when GWT uses a fallback user.agent property?

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.

Debug portal_skins order for Dexterity content types

We have one Plone site (4.3.x) using TinyMCE version 1.4.3, but we found that we should have the version 1.3.18 instead for this Plone version.
So I:
Uninstalled the TinyMCE package ( manage / portal_setup / import / Remove TinyMCE profile ).
Pin buildout version to 1.3.18 and run buildout.
Reinstalled TinyMCE package ( same procediment, but select TinyMCE install profile).
After that I notice that:
For default Plone content types it worked fine.
For the new dexterity content types defined in this Plone Site it didn't work. It load just a textarea with html into it instead of load TinyMCE.
I did many tests on this, and what I can see is that my content type should use wysiwygEditorBox macro from this template Products/TinyMCE/skins/tinymce/tinymce_wysiwyg_support.pt but instead it is using this template Products/CMFPlone/skins/plone_wysiwyg/wysiwyg_support.pt.
I tried to change order of portal_skins but it just affect Archetypes types, not Dexterity types.
What step should I do next? is there any better way to debug it instead of adding <span> tags with debug messages?
Looking in the parts/omelette directory shows the following in plone/app/form/widgets/wysiwygwidget.pt (line 21)
support_path string:nocall:here/${editor}_wysiwyg_support|here/${editor}/wysiwyg_support|here/po
My guess is that ${editor} isn't set right (ie to tinymce) so the above line is falling back to search for the wysiwyg_support.pt template.

What user.agent property value should i use in gwt.xml for FF21?

I want to reduce the time it takes in devmode to turn my gwt app into javascript. For that i'm thinking of limiting the user.agent values to the one corresponding to FF21. gecko1_8 is suggested to be for FF3. And gecko1_9 does not work
There is only one firefox user agent and is gecko1_8. It targets the gecko engine 1.8 and onwards, hence FF >= 1.5 according to this.
Have a look at here to find all the available user agents you can use.

Prevent application from running on a particular browser

When I build a GWT application, it runs on all browsers like IE,chrome,firefox etc. provided GWT plugin is installed for that browser.
I want to know how can I prevent a GWT application from running on a particular browser i.e. if I don't want my GWT apps to run on say Firefox, how can I achieve that? What changes I need to do in my code?
Add <set-property name="user.agent" value="ie6,ie8,ie9,safari,opera" /> to your *.gwt.xml file and it will fail to load in Firefox (FYI, Firefox's user.agent token is gecko1_8).
If you don't want to support IE6 and IE7 for instance, you don't need to compile for them, and you can decrease your compilation time by removing the ie6 token from the user.agent value list.