You are on page 1of 1

MINILANG COOKBOOK

=================
* How to get results of a Java static method in minilang
Use set and bsh:
<set field="notApplied" value="${bsh:org.ofbiz.accounting.invoice.InvoiceWorker.
getInvoiceNotApplied(invoice)}" type="Double"/>
WARNING: YOU MUST USE type="" TO CAST YOUR RESULT. Otherwise, it will be a Stri
ng.
* How to invoke Java from inside minilang
You can actually insert blocks of beanshell code right into minilang, like thi
s example
from applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.x
ml:
<call-bsh><![CDATA[
String password = (String) userLoginContext.get("currentPassword");
String confirmPassword = (String) userLoginContext.get("currentPassw
ordVerify");
String passwordHint = (String) userLoginContext.get("passwordHint");
org.ofbiz.securityext.login.LoginServices.checkNewPassword(newUserLo
gin, null, password, confirmPassword, passwordHint, error_list, true, locale);
]]></call-bsh>
Each variable from minilang is automatically accessible here in beanshell.

* Clear vs. Refresh
<clear-field field-name="foo"/> sets it to null. It can be either a field or
a Map/GenericValue
<refresh-value value-name="foo"/> gets the value of a GenericValue foo from da
tabase again. foo MUST be a GenericValue for it to work.
* How to set a Boolean value
I could not find any examples of this but fortunately got lucky doing this:
<set field="orderAvailableCtx.countNewReturnItems" value="true" type="Boolean
"/>
I think what minilang does is call the constructor for type="" using the stri
ng of value="". I guess one of these days I should look at the code to see if I
'm right...

You might also like