Screen Widget Actions in Java

From Opentaps Wiki

Jump to: navigation, search

As part of opentaps 1.4, we are introducing Java actions for the ofbiz screen widget based on OFBIZ-44. This allows you to write the data preparation logic of a screen in Java instead of scripting languages.

To use this feature, in your screen widget XML, use the java directive to invoke your Java class and method:

<screen name="findAndListInvoices">
   <section>
      <actions>
         <java location="com.opensourcestrategies.financials.invoice.InvoiceActions" invoke="findInvoices"/>
      </actions>

Your Java method must be a static method which accepts a Map of the context as a parameter:

public static void findInvoices(Map<String, Object> context) throws GeneralException, ParseException {

The context contains environment variables as well as parameters for your screen. Opentaps has an org.opentaps.foundation.action.ActionContext which takes the Map and allows you to obtain environment variables from it and put values back into the context for your screen:

final ActionContext ac = new ActionContext(context);
// ... for example
String invoiceTypeId = ac.getString("invoiceTypeId");
// ... for example
ac.put("processingStatuses", processingStatusList);


© Open Source Strategies, Inc. Development of this documentation site is sponsored by Open Source Strategies, Inc.
Help support opentaps with a subscription to this documentation site.