Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Scanner Application with injected JavaScript(Production mode removes "data-classid" attribute)
Scanner Application with injected JavaScript [message #1798933] Tue, 27 November 2018 15:05 Go to next message
Bernard Brinkhus is currently offline Bernard BrinkhusFriend
Messages: 3
Registered: October 2017
Junior Member
I am writing a Scanner-Application for an Android Scanner using an Enterprise Browser (basically Chromium) with a JavaScript interface for the Scanner.

I wrote a JavaScript where a Callback delivers the Bar-code and I write it to the respective Form-fields. In my JavaScript I use the "data-classid" attribute to identifying the Form-fields.

This all works fine in development mode, but the production mode removes all identifying attributes.

Here is now my question: How can I identify a Form-field within a JavaScript to deliver my Bar-codes to and which does not change?

Thanks,
Bernard

I am using the Photon Release of Scout.
Re: Scanner Application with injected JavaScript [message #1799021 is a reply to message #1798933] Wed, 28 November 2018 20:02 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 114
Registered: November 2010
Senior Member
Hi Bernard,

In development mode, classIds and model class names are transferred to the UI to help with debugging. Because this information is usually internal (and internal information should not be exposed for security reasons), it is not activated on production environments. If you allow it by setting the config property scout.urlHints.enabled=true in your config.properties you may activate the feature dynamically using the URL parameter ?inspector=true. But this is mainly intended for automatic testing (e.g. using the Selenium testing framework that also requires stable IDs) and should not be done on applications exposed to the internet. Reason: enabling the property also allows bypassing minification and caching.

So you can do three things:
1. @Replace the bean org.eclipse.scout.rt.ui.html.json.InspectorInfo (have a look at the code, it is very short) and implement it without the check "if inspector hints enabled". This will then always emit the inspector properties.
2. If you only require a special marker for one specific field in your application, consider adding a custom JS implementation that adds a special marker attribute in the _render() method. This is done most easily with a @ModelVariant, you can read more about this mechanism here: https://eclipsescout.github.io/8.0/technical-guide.html#extensibility
3. Most basic solution: override getConfiguredCssClass() and set a css class with a unique name that does not influence the style but is only used by your scanner to find the field.

Regards,
Beat
Re: Scanner Application with injected JavaScript [message #1799082 is a reply to message #1799021] Thu, 29 November 2018 15:20 Go to previous message
Bernard Brinkhus is currently offline Bernard BrinkhusFriend
Messages: 3
Registered: October 2017
Junior Member
Hi Beat,

I have decided to go with solution 3 and it works like a charm and it only affects the Form-Fields I am using for the bar-codes.

Thanks again,
Bernard
Previous Topic:Icons disapear when setting permission
Next Topic:Eclipse Scout 8.0 (Photon) now available
Goto Forum:
  


Current Time: Mon Dec 09 00:52:39 GMT 2019

Powered by FUDForum. Page generated in 0.01768 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top