Helllo
I'm new to ofbiz (12.04.02) I'm trying to implement my first groovy service. According to the documentationOFBiz DSL for Groovy Services and Events <https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+DSL+for+Groovy+Services+and+Events> I have my service method implemented as def myMethod() { return success() } when success() is executed in org.ofbiz.service.engine.GroovyBaseScript a MissingPropertyException is triggered def success(String message) { // TODO: implement some clever i18n mechanism based on the userLogin and locale in the binding if (this.binding.getVariable('request')) { // the script is invoked as an "event" 'request' is not in the binding as the script is called as a service instead of as event. Shouldn't the line be as if (this.binding.hasVariable('request')) { so do not throw Missing exception ? Am I doing something wrong or it is worth to file an issue ? At the moment I have patched the code as below: =================================================================== --- framework/service/src/org/ofbiz/service/engine/GroovyBaseScript.groovy (revision 1569402) +++ framework/service/src/org/ofbiz/service/engine/GroovyBaseScript.groovy (revision ) @@ -55,7 +55,7 @@ def success(String message) { // TODO: implement some clever i18n mechanism based on the userLogin and locale in the binding - if (this.binding.getVariable('request')) { + if (this.binding.hasVariable('request')) { // the script is invoked as an "event" return 'success'; } else { @@ -77,7 +77,7 @@ } def error(String message) { // TODO: implement some clever i18n mechanism based on the userLogin and locale in the binding - if (this.binding.getVariable('request')) { + if (this.binding.hasVariable('request')) { // the script is invoked as an "event" if (message) { this.binding.getVariable('request').setAttribute("_ERROR_MESSAGE_", message) Thank you for yor attention. Paolo Piersanti -- Signature for Rent - Questo spazio si affitta Paolo Piersanti Software Developer & System Admininistrator smime.p7s (5K) Download Attachment |
Hi Paolo,
you are indeed right, the code is still experimental and needs some love! I have committed your fix in rev. 1569743 (trunk), rev. 1569746 (for 13.07) and rev. 1569750 (for 12.04). Please keep us updated on the results of your tests and work: I am interested in improving this part of the system and your feedback will be valuable. Jacopo On Feb 19, 2014, at 2:03 PM, Paolo Piersanti <[hidden email]> wrote: > Helllo > I'm new to ofbiz (12.04.02) > > I'm trying to implement my first groovy service. > According to the documentationOFBiz DSL for Groovy Services and Events <https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+DSL+for+Groovy+Services+and+Events> > I have my service method implemented as > > def myMethod() { > return success() > } > > when success() is executed in org.ofbiz.service.engine.GroovyBaseScript > a MissingPropertyException is triggered > > def success(String message) { > // TODO: implement some clever i18n mechanism based on the userLogin and locale in the binding > if (this.binding.getVariable('request')) { > // the script is invoked as an "event" > > 'request' is not in the binding as the script is called as a service instead of as event. > > Shouldn't the line be as > > if (this.binding.hasVariable('request')) { > > so do not throw Missing exception ? > > Am I doing something wrong or it is worth to file an issue ? > > At the moment I have patched the code as below: > > =================================================================== > --- framework/service/src/org/ofbiz/service/engine/GroovyBaseScript.groovy (revision 1569402) > +++ framework/service/src/org/ofbiz/service/engine/GroovyBaseScript.groovy (revision ) > @@ -55,7 +55,7 @@ > > def success(String message) { > // TODO: implement some clever i18n mechanism based on the userLogin and locale in the binding > - if (this.binding.getVariable('request')) { > + if (this.binding.hasVariable('request')) { > // the script is invoked as an "event" > return 'success'; > } else { > @@ -77,7 +77,7 @@ > } > def error(String message) { > // TODO: implement some clever i18n mechanism based on the userLogin and locale in the binding > - if (this.binding.getVariable('request')) { > + if (this.binding.hasVariable('request')) { > // the script is invoked as an "event" > if (message) { > this.binding.getVariable('request').setAttribute("_ERROR_MESSAGE_", message) > > > Thank you for yor attention. > > Paolo Piersanti > > > > > -- > Signature for Rent - Questo spazio si affitta > Paolo Piersanti Software Developer & System Admininistrator > > |
On 19/02/14 15:27, Jacopo Cappellato wrote:
> Hi Paolo, > > you are indeed right, the code is still experimental and needs some love! I have committed your fix in rev. 1569743 (trunk), rev. 1569746 (for 13.07) and rev. 1569750 (for 12.04). > Please keep us updated on the results of your tests and work: I am interested in improving this part of the system and your feedback will be valuable. Hi Jacopo, ok, it will be glad. Thank you for your support! Paolo -- Signature for Rent - Questo spazio si affitta Paolo Piersanti Software Developer & System Admininistrator smime.p7s (5K) Download Attachment |
Free forum by Nabble | Edit this page |