Hello,

So you cannot call groovy, or any other programming language for that matter, 
from your browser. The only thing you can call from the browser is javascript 
and the DOM.

So if you want to wire a button to some piece of code that you would like to 
execute, then this is simply a good-old http-request / http-response thing just 
like in any other technology / programming language / framework.

So what you want to do, is to call an end-point that is defined in 
Controller.xml and pass whatever parameters you need to it, and from there now 
you're in server-land and you can do whatever you're used to in OFBiz. Note 
that it's quite different to call an HTTP end-point by submitting a form (the 
browser does it) vs calling it from Javascript (you do it) because in the 
latter case you are not redirected to another page.

In other words, perhaps the problem is simply not differentiating between what 
is server-side code and client-side code. If you make the distinction clear 
then you just realize it's a matter of HTTP communication between the two.

I hope this helps!

Cheers,

Taher Alkhateeb

On Tuesday, January 24, 2023 04:09 +03, Ernest Hocking 
<[email protected]> wrote:
 Hi everyone

I'd like to use groovy to implement some business logic and call that logic
from a button in a form.

E.g Add a button on the product measures form to calculate the volume
given a product's dimensions.. I've tried

<field name="calcTest" title=" " widget-style="buttontext">
<hyperlink description="Calculate C" target="testCalc"
also-hidden="false">
<parameter param-name="scale-factror"/>
<!-- e.g add an allowance for packing material -->
</hyperlink>
</field>
I can call/test the service "testCalc" from webtools etc but not use the
button.

Can anyone point me to an example in the existing code base that I can use
as a reference model.

thanks in advance

Ernest

Reply via email to