This is an automated email from the ASF dual-hosted git repository. nmalin pushed a commit to branch release24.09 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/release24.09 by this push: new 8f5412a6f2 Improved: Allow GroovyDSL in FlexibleStringExpander (OFBIZ-13133) (#833) 8f5412a6f2 is described below commit 8f5412a6f205a9d685b050d798b11f1431d0e615 Author: Charles <72392645+charlesnere...@users.noreply.github.com> AuthorDate: Wed Oct 2 15:43:16 2024 +0200 Improved: Allow GroovyDSL in FlexibleStringExpander (OFBIZ-13133) (#833) Improved: Allow GroovyDSL in FlexibleStringExpander (OFBIZ-13133) (#833) * With this, you can call easily groovy dsl in Scriptlet : ``` ${groovy: from('Party').where(partyId:'admin').queryOne()} ${groovy: label('PartyUiLabels', 'PartyPartyNotFound')} ``` * add example on manufacturing screen to replace method getMessage() by label() one to demonstrate improvement * javadoc correction (missing @param name) --- .../manufacturing/widget/manufacturing/MrpScreens.xml | 2 +- .../java/org/apache/ofbiz/base/util/GroovyUtil.java | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/applications/manufacturing/widget/manufacturing/MrpScreens.xml b/applications/manufacturing/widget/manufacturing/MrpScreens.xml index 3997e0ea23..8d1639725a 100644 --- a/applications/manufacturing/widget/manufacturing/MrpScreens.xml +++ b/applications/manufacturing/widget/manufacturing/MrpScreens.xml @@ -61,7 +61,7 @@ under the License. <set field="tabButtonItem" value="RunMrp"/> <set field="helpAnchor" value="_run_mrp"/> <set field="headerItem" value="mrp"/> - <set field="eventMessage" value="${groovy: org.apache.ofbiz.base.util.UtilProperties.getMessage('ManufacturingUiLabels', 'ManufacturingMrpRunScheduledSuccessfully', locale)}"/> + <set field="eventMessage" value="${groovy: label('ManufacturingUiLabels','ManufacturingMrpRunScheduledSuccessfully')}"/> </actions> <widgets> <decorator-screen name="CommonMrpDecorator"> diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java index c1a57f0160..c2f8ed32e0 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java @@ -187,11 +187,21 @@ public final class GroovyUtil { } } + /** + * Parses a Groovy class from a text. + * @param text as flexible string to parse + * @return the corresponding class object + * @throws IOException when parsing fails + */ public static Class<?> parseClass(String text) throws IOException { - GroovyClassLoader groovyClassLoader = new GroovyClassLoader(); - Class<?> classLoader = groovyClassLoader.parseClass(text); - groovyClassLoader.close(); - return classLoader; + if (GROOVY_CLASS_LOADER != null) { + return GROOVY_CLASS_LOADER.parseClass(text); + } else { + GroovyClassLoader groovyClassLoader = new GroovyClassLoader(); + Class<?> classLoader = GROOVY_CLASS_LOADER.parseClass(text); + groovyClassLoader.close(); + return classLoader; + } } /**