如何将参数传递到ofbiz中的groovy脚本

发布于 2025-02-05 08:14:15 字数 1746 浏览 3 评论 0原文

我是Ofbiz的初学者开发者。 我想使用FreeMarker模板处理一些汽车数据并显示主题。

首先,我单击 carid 单击到一个名为 cardetail 的屏幕,然后我想将其传递给一个groovy脚本,该脚本将查询数据库并发送回一个观察结果。该观察结果将传递给自由标记模板。

我不是问题所在。这是屏幕的代码。

<screen name="carDetail">
    <section>
        <actions>
            <set field="carId" from-field = "parameters"/>
            <script location="component://ParcAutomobile/groovyScripts/find.groovy"/>
        </actions>
        <widgets>
            <decorator-screen name="ParcAutomobileCommonDecorator" location="${parameters.mainDecoratorLocation}">
                <decorator-section name="body">
                    <platform-specific>
                        <html>
                            <html-template location="component://ParcAutomobile/groovyScripts/list.ftl"></html-template>
                        </html>
                    </platform-specific>
                </decorator-section>
            </decorator-screen> 
        </widgets>
    </section>
</screen>

然后,我想通过Groovy进行观察。

carId = parameters.carId
context.carId = carId
car = from("Car").where("carId", carId).queryOne()
context.car = car

最后在freemarker模板中显示它

<div>
<#if car?has_content>
<table>
        <tr>
            <th>${uiLabelMap.CarId}</th>
            <th>${car.carId}</th>
        </tr>
        <tr>
            <th>${uiLabelMap.CarId}</th>
            <th>${car.carId}</th>
        </tr>
</table>
</#if>
</div>

可以帮助我解决此问题。

I'm beginner Developper in OFBiz.
i want to process some car data and display theme with freeMarker template.

first i send the carId on click to a screen named carDetail i want then to pass it to a groovy script which will query the database and send back one observation. the observation will be pass to a freeMarker template.

I don't where is the problem. here is the code of the screen.

<screen name="carDetail">
    <section>
        <actions>
            <set field="carId" from-field = "parameters"/>
            <script location="component://ParcAutomobile/groovyScripts/find.groovy"/>
        </actions>
        <widgets>
            <decorator-screen name="ParcAutomobileCommonDecorator" location="${parameters.mainDecoratorLocation}">
                <decorator-section name="body">
                    <platform-specific>
                        <html>
                            <html-template location="component://ParcAutomobile/groovyScripts/list.ftl"></html-template>
                        </html>
                    </platform-specific>
                </decorator-section>
            </decorator-screen> 
        </widgets>
    </section>
</screen>

then i want to get an observation by doing this with groovy.

carId = parameters.carId
context.carId = carId
car = from("Car").where("carId", carId).queryOne()
context.car = car

finally display it in freeMarker template

<div>
<#if car?has_content>
<table>
        <tr>
            <th>${uiLabelMap.CarId}</th>
            <th>${car.carId}</th>
        </tr>
        <tr>
            <th>${uiLabelMap.CarId}</th>
            <th>${car.carId}</th>
        </tr>
</table>
</#if>
</div>

help me fix this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文