How to use <uiInclude> tag ?

I would like to import a JavaScript file, to be available in my HTML Form Entry form. I see the <uiInclude> tag in the documentation ([here][1])

When I simply add it in my form, it doesn’t seem to do anything.

My resource is located in /mymodule/omod/src/main/webapp/resources/scripts/myJS.js and the line I add is:

<uiInclude provider="mymodule" javascript="myJS.js"/>

versions:

  • HTML Form Entry 2.6-SNAPSHOT
  • HTML Form Entry Extensions for OpenMRS 1.9 Module 1.5
  • HTML Form Entry UI Framework Integration Module 1.2
  • OpenMRS UI Framework 3.3.1

There is no error reported in the server log, nor in the console of Chrome’s Debug window.

What to do ?

(not sure if I should use Implementing or Developers category for the HFE related questions) [1]: https://wiki.openmrs.org/display/docs/HTML+Form+Entry+Module+HTML+Reference#HTMLFormEntryModuleHTMLReference-

What you are doing looks right, at a glance.

Check the generated HTML and see if uiInclude was replaced, or if it is still included verbatim in the output.

(Generally Developers seems better for a question like this.)

Nope, it is not replaced.

See the output HTML from the page loaded :

What would be a good place for my breakpoint to debug ?

Was your original code “uiinclude” or “uiInclude”? Tags may be case-sensitive, I don’t recall.

Yes it is <uiInclude> with big “I”

After updating HTML Form Entry UI from htmlformentryui-1.2 to htmlformentryui-1.3-SNAPSHOT it works.

Note that I also made a mistake on the screenshot above as I’ve tried to include the scripts/testScript.js file but with the argument “javascript” provider, it is assumed that the script is already located in $provider/omod/src/main/webapp/resources/scripts/

Problem solved for me, but we may want to investigate further since the htmlformentryui-1.2 is the one provided in the Reference Application bundle ?

I guess we just need to release a new version of the htmlformentryui module. (Though I’m surprised this feature isn’t released yet. I thought we introduced it a long time ago.)

At a quick glance, there IS a UiIncludeTagHandler.java class in v1.2 but it is never called :confused:

The HTMLFormEntryUIFrameworkIntegrationActivator.java seems to add the Handler for <uiMessage> tag only, and not for <uiInclude>. See below:

Yep, looking at the master branch, it looks I only added the setup of the uiInclude handler in May of this year. Obviously it was an oversight that it wasn’t added when first created, but I don’t remember if there was some reason why the tag was still working in some cases even without being set up here.

OK thank you for the answers. Working now in master branch. Could we mark the thread as resolved ?

Sure, let mark it as resolved.