How to pass parameters to groovy script in OFBiz

101 views Asked by At

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.

0

There are 0 answers