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)
Code Block language javascript 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 },
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.Code Block language javascript 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' }] });
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:Code Block Chrome: --allow-file-access-from-files Safari: --disable-web-security
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.
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:-Code Block 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 },
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.Code Block 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.- Problem: OpenMRS has memory leaks when choosing 'Reload' or 'Stop' and 'Start' in Tomcat
...
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:
Code Block |
---|
[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: use @Transactional on your ResourceService.java interface
15. Symbol not found exception when running controller tests
Solution: run clean and build on the entire module, then run tests on the controllers.