Cannot find controller or view for fragment

Application Name: Platform Version Number: 1.11.6 Modules: uicommons 1.9-SNAPSHOT Other: registration.json to add a custom widget

I have created a widget called textareanew. Am creating a fingerprint widget by mimicking existing widgets. I have added the same to the .json file in the registration page.

Question: What should my controller have for this to work?

Here is what my json looks like.

    "fields": [
                                  {
                                   "type": "personAttribute",
                                   "label": "AAACapture FingerPrint",
                                   "formFieldName": "leftIndexFingerPrint",
                                   "uuid": "0fe8824e-f9f8-42fa-a919-4d2dcd00a5da",
                                   "widget": {
                                              "providerName": "uicommons",
                                              "fragmentId": "field/textareanew"
                                             }
                                   }
                                  ]

Error java.lang.RuntimeException: Cannot find controller or view for fragment: field/textareanew at

Will be glad to get practical examples. @mogoodrich @wyclif @mksd @dkayiwa

Hi @smuwanga

Looking at:

{
  "providerName": "uicommons",
  "fragmentId": "field/textareanew"
}

This suggests that textareanew.gsp lives in the UI Commons module, did you fork it and add a new widget in it?

Yes, I forked it as follows;

  1. Duplicated the fragment textarea.gsp, and renamed it to textareanew.gsp in uicommons-omod/src/main/webapp/fragments/field/textareanew.gsp
  2. Did the same for org.openmrs.module.htmlwidgets.web.html.TextAreaWidget to get TextAreaNewWidget

So it seems as if we have the view. The controller for the fragment is what we don’t have yet.

These fields don’t seem to need a controller (as in all these widgets not residing right under /fragments). I have successfully designed and used such a custom field when I set up our registration app back in the days. But there are two differences to your case:

  1. It was recording an obs, and not a person attribute.
  2. It was brought in by our own module.

I don’t think 1 matters though. Could you share the full stack trace on some paste bin tool?

http://paste.ubuntu.com/16258710/

The provider name is the artifactId of your module.

Am working with uicommons. So it’s artifact Id seems to be well spelled.

@smuwanga so did you fork uncommons? I think that’s a bad idea better to create your own custom module and create the fragments as you need them.

This is one of for gems within OpenMRS that follows the principle of closed for modification and open for extension.

@ssmusoke, am extending uicommons.

I have not created a new module as per this post. Could you possibly share some tips on how to create a new widget, more so with the ui-commons module?

I did this for a language custom dropdown field for our registration form:

Hopefully this will help you pinpoint some differences that would be causing the trouble.

As as I said, this custom fragment records an obs (and not a person attribute) and is brought in through another module than UI Commons. However at first glance I don’t see why either would make a difference.

As @mksd says, you don’t need a controller. (Also, you don’t need to touch the htmlwidgets module for this – it’s only used by the reporting module in its legacy ui admin screens.)

What you describe seems like it should work. Dumb question: did you actually build the forked uicommons module and install it in your application? And if you’re using “development mode” is it pointing to the right place?

As a last resort, you can run things under the debugger, and put a breakpoint a bit before org.openmrs.ui.framework.fragment.FragmentFactory.processThisFragment(FragmentFactory.java:184) and trace the code to see what’s happening…

As @ssmusoke says, I think it’s bad practice to fork a module, you’re better off writing your own module, or add the feature directly to an existing module without forking it

Thanks guys( @darius @mksd @ssmusoke @wyclif )

@darius I have not forked any module. Things done so far

  1. I created a person attribute.

  2. I created a new fragment in uicommons as shown in this picture.

  3. Then added it to registration.json as below “fields”: [ { “type”: “personAttribute”, “label”: “AAACapture FingerPrint”, “formFieldName”: “leftIndexFingerPrint”, “uuid”: “0fe8824e-f9f8-42fa-a919-4d2dcd00a5da”, “widget”: { “providerName”: “uicommons”, “fragmentId”: “field/textareanew” } } ]

@smuwanga, your point 2. above suggests that you are indeed forking UI Commons since you are modifying it. Making the change shown in your screenshot is not enough. As @darius hinted, you still need to build this module and install the built .omod file on your OpenMRS instance.

But as @wyclif suggested, you should do all the above as part of a custom module that brings in the new functionality that you are working on.

Thanks people. I managed to build a module, created a fragment as at Using UI Framework. The fragment works pretty well. I have placed applet tags, but gsp doesn’t render the applet as it was in jsp and html.

Question: How can I embed the applet into this fragment? @mksd @slubwama @carapai @ssmusoke @wyclif @darius @dkayiwa

GSP allows all html tags, in general, so I don’t think that is where the problem is.

-Darius (by phone)

@darius,

Thanks for the pointer. I used javascript to deploy the applet as below;

<% ui.includeJavascript(“myModuleId”, “gsp_applet_deployer.js”); %>

            <script>
                    var attributes = {
                    name:'fingerApplet',
                    codebase:'/openmrs',
                    code:'org.openmrs.module.fingerprint.applet.PatientEnrollmentApplet.class',
                    archive:'finger_print_applet.jar',
                    width:600, height:300} ;
                   var parameters = {patientId:16} ;
                   var version = '1.6' ;
                   deployJava.runApplet(attributes, parameters, version);
                </script>                 

Am looking for ways to save the fingerprint template on clicking “Confirm” button on the registration page. Started working person attributes + complex datatypes now.

Here is what the registration page looks like after deploying the applet.

Am happy to get more guidance. @mksd @wyclif @darius @k_joseph @dkayiwa .

Reference:

  1. gsp_applet_deployer.js was adopted from http://java.com/js/deployJava.js