mksrom
(Romain Buisson)
August 31, 2015, 4:51am
1
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-
darius
(Darius Jazayeri)
September 1, 2015, 9:00pm
2
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.)
mksrom
(Romain Buisson)
September 2, 2015, 11:54am
3
Nope, it is not replaced.
See the output HTML from the page loaded :
What would be a good place for my breakpoint to debug ?
mogoodrich
(Mark Goodrich)
September 2, 2015, 1:42pm
4
Was your original code “uiinclude” or “uiInclude”? Tags may be case-sensitive, I don’t recall.
mksrom
(Romain Buisson)
September 2, 2015, 2:25pm
5
Yes it is <uiInclude>
with big “I”
mksrom
(Romain Buisson)
September 2, 2015, 2:45pm
6
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 ?
darius
(Darius Jazayeri)
September 2, 2015, 4:53pm
7
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.)
mksrom
(Romain Buisson)
September 3, 2015, 3:16am
8
At a quick glance, there IS a UiIncludeTagHandler.java class in v1.2 but it is never called
The HTMLFormEntryUIFrameworkIntegrationActivator.java seems to add the Handler for <uiMessage>
tag only, and not for <uiInclude>
.
See below:
* This class contains the logic that is run every time this module is either started or stopped.
*/
public class HTMLFormEntryUIFrameworkIntegrationActivator extends BaseModuleActivator {
protected final Log log = LogFactory.getLog(getClass());
@Override
public void started() {
try {
HtmlFormEntryService htmlFormEntryService = Context.getService(HtmlFormEntryService.class);
htmlFormEntryService.addHandler(HtmlFormEntryUiConstants.HTMLFORMENTRY_UI_MESSAGE_TAG_NAME, new UiMessageTagHandler());
}
catch (Exception e) {
Module mod = ModuleFactory.getModuleById(HtmlFormEntryUiConstants.MODULE_ID);
ModuleFactory.stopModule(mod);
throw new RuntimeException("failed to setup the " + HtmlFormEntryUiConstants.MODULE_ID + " module", e);
}
log.info("HTML Form Entry UI Framework Integration module started");
}
mogoodrich
(Mark Goodrich)
September 3, 2015, 2:18pm
9
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.
mksrom
(Romain Buisson)
September 13, 2015, 5:04am
10
OK thank you for the answers.
Working now in master branch. Could we mark the thread as resolved ?
mogoodrich
(Mark Goodrich)
September 14, 2015, 1:37pm
11
Sure, let mark it as resolved.