Find descendant method in Html Form Entry only matches nodes with children

HtmlFormEntryUtil.findDescendant() method will only find an element if the element has one or more children. Was this the intended behaviour?

In the snippet below when searching for “obs” using HtmlFormEntryUtil.findDescendant, it will return null for the first case.

<htmlform><obs conceptId="2" /></htmlform>
<htmlform><obs conceptId="2">Some Content</obs.</htmlform>

cc @darius @mogoodrich

What Node are you passing in as the first parameter to the findDescendant method? If the Node is the top-level , then, yes, it should find the obs node. However, if you are starting with the obs node and searching for obs, it should return null.

It does seem wrong if you are getting a different result for each of the cases you listed above.

I’m passing in htmlform as the first node

Document document = HtmlFormEntryUtil.stringToDocument("<htmlform><obs conceptId="2" /></htmlform>");
Node obsNode = HtmlFormEntryUtil.findDescendant(document, "obs");

@mogoodrich I have created a ticket here: https://issues.openmrs.org/browse/HTML-592

1 Like

I am new to the OpenMRS project and am tackling this bug to get into development. What modules are necessary to run the HTML Form Entry Module. I have had some problems with the UI framework and strange dependencies with the Form Entry modules. I am getting an http 500 server error with the UI framework.

I believe that there aren’t any specific modules required to run the HFE module, though if you are using version 2.x of OpenMRS, you will probably need the legacy ui module.

Dependency requirements for a module can be found in it’s config.xml file.

Take care! Mark

Thank you @Mogoodrich. I have done some digging and am moving forward by looking at creating a unit test to see if I can expose the issue. I have blogged on this bug for my class to articulate my work and thinking. The blog post can be found here.