Common blockers & solutions

  1. Problem:- Using button from controller

    Solution:- Use the following code in the controller (in view write action:addModify in properties of button whose action is to be defined)

    init: function () {
        this.control({
            //addDrug is alias of view & addModify is action given to button in view
            'addDrug button[action=addModify]': {
                click: this.updateUser
            }
        });
    },
    updateUser: function (button) {
        //write your function here
    },
    


  2. Problem:- How to make the nested model
    Solution:- You don't need to use association for that just in fiels add {name : "name","model":"model of that field"}, You can see in the following code that the last field instead of using type model is used to make it a nested model.

    Ext.define('Registration.model.Person', {
        extend: 'Ext.data.Model',
        fields: [{
            name: 'id',
            type: 'number'
        }, {
            name: 'gender',
            type: 'string'
        }, {
            name: 'age',
            type: 'string'
        }, {
            name: 'uuid',
            type: 'string'
        }, {
            name: 'names',
            model: 'Registration.model.names'
        }]
    });
  3. Problem:- Cannot load local json/resource files using Ajax (XMLHttpRequest cannot load file:///D:/Raxa-JSS/src/doctors.json?_dc=1339103245708. Origin null is not allowed by Access-Control-Allow-Origin.)
    Solution:- Due to browser security local files cannot be loaded by Ajax. Different browsers use different flags (add the parameters to your browser launch shortcut icon), but following are some that most Raxa devs use:

    Chrome: --allow-file-access-from-files
    Safari: --disable-web-security
  4. Problem:- Unable to give root of a Json file in Sencha Touch 2 

    Solution:- Use rootProperty instead of root in the store. refer to sencha docs for more information.

  5. Problem:- How to stop some field(like "id") in model to be sent in body of the rest calls?

    Solution:- use "persist=false" property while defining the fields. For eg:-

    fields: [{
            name: 'id',
            //every model have a id field by default and it shouldn't go with post call's body so
            //we defined it and made the persist property false 
            persist: false 
        },
  6. Problem:- How to change the persist property in controller to change it dynamically according to the data?

    Solution:- below is an example in which the age field some time can have value n some times not, as openmrs server don't accept empty fields(gives 500 response status) it was need to change its persist property if empty or not. So, this is how i did it.

    if (Ext.getCmp('patientAge').isValid()) {
                jsonperson.data.age = Ext.getCmp('patientAge').value;
                Registration.model.Person.getFields()[2].persist = true;
            } else {
                Registration.model.Person.getFields()[2].persist = false;
            }

    "Registration.model.Person" is the model i am using to create the person, it contain the "age" field at index 2 of fields array of model.
    NOTE:- Above solution works just for Extjs and not sencha touch.

  7. Problem: OpenMRS has memory leaks when choosing 'Reload' or 'Stop' and 'Start' in Tomcat
          Solution: 1. Stop the tomcat service. (Be patient, stopping after a memory leak generally takes time)
                        2. Browse to the tomcat webapps directory and delete the openmrs directory. (If it says can not delete 101 .jar files as they are in use, ensure that you successfully stopped tomcat)
                        3. Browse to C:\Application Data\OpenMRS\modules and delete the custom modules that you had added.
                        4. Start tomcat service again.
                        5. Open localhost:8080/openmrs and give it some time to build the openmrs files again
                        6. OpenMRS should be up and running again! (smile)
 
     8. Problem: Error occurred while trying to get the updates needed for the database. Validation Failed while trying to start OpenMRS
          Solution: modify liquibase-update-to-latest.xml checksums as indicated here: https://wiki.openmrs.org/display/docs/How+to+Modify+a+Bad+Changeset

     9. View not displayed properly in pop-up panel( especially a list ).
         Solution: Try layout: 'fit', as sometimes the view is being displayed but not at the correct place.

    10. Tests do not show correct results in raxacore
 
        Solution: As there is some demo data in openmrs for 1.8 & we are using 1.9 version right now, so try making your own data completely independent of openmrs data in moduleTestData file.

    11. Raxacore Bug - something like: WARN - ServiceContext.getService(706) |2012-07-03 02:47:23,989| Waiting to get service: interface org.raxa.module.raxacore.PatientListService while the context is being refreshed
       
 Solution: Try this link  http://listarchives.openmrs.org/Waiting-to-get-service-interface-org-openmrs-api-AdministrationService-td6010736.html 

    12. Back end development error: A user context must first be passed to setUserContext()...use Context.openSession() (and closeSession() to prevent memory leaks!) before using the API
         Solution: Don't use setUserContext() or Context.authenticate(), you should already be authenticated

    13. Raxacore build error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.4:unpack-dependencies (Expand moduleApplicationContext and messages) on project raxacore-omod: Error unpacking file: /Users/adiaz/projects/raxacore/api/target/classes to: /Users/adiaz/projects/raxacore/omod/target/classes
[ERROR] org.codehaus.plexus.archiver.ArchiverException: The source must not be a directory.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.4:unpack-dependencies (Expand moduleApplicationContext and messages) on project raxacore-omod: Error unpacking file: /Users/adiaz/projects/raxacore/api/target/classes to: /Users/adiaz/projects/raxacore/omod/target/classes
org.codehaus.plexus.archiver.ArchiverException: The source must not be a directory.

        Solution: don't use "mvn compile" – do an "mvn clean" and then "mvn -Dskiptests install"

     14. Help! My everything seems to work but none of my POSTs are persisted to the database!

        Solution: use @Transactional on your ResourceService.java interface

     15. Symbol not found exception when running controller tests:

 

COMPILATION ERROR : 
-------------------------------------------------------------
org/raxa/module/raxacore/web/v1_0/controller/RaxaAlertController.java:[116,12] cannot find symbol
symbol : method setToLocationId(java.lang.Integer)

        Solution: run clean and build on the entire module, then run tests on the controllers. Do not build/test on just the OMOD part of the project until the entire project has been built once.

    16. Exception occurred inside setter hibernate.propertyAccessException

        Solution: check each setXX() methods in your Java object. Make sure each setter is only access it's own member variable. One setter accessing another's private member may cause this exception.