Difference between revisions of "Screen Widget Actions in Java"

From Opentaps Wiki
Jump to navigationJump to search
(New page: As part of opentaps 1.4, we are introducing Java actions for the ofbiz screen widget based on [https://issues.apache.org/jira/browse/OFBIZ-44 OFBIZ-44]. This allows you to write the data p...)
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
As part of opentaps 1.4, we are introducing Java actions for the ofbiz screen widget based on [https://issues.apache.org/jira/browse/OFBIZ-44 OFBIZ-44]. This allows you to write the data preparation logic of a screen in Java instead of scripting languages.
+
As part of opentaps 1.4, we are introducing Java actions for the ofbiz screen widget based on [http://issues.apache.org/jira/browse/OFBIZ-44 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 <tt>java</tt> directive to invoke your Java class and method:
 
To use this feature, in your screen widget XML, use the <tt>java</tt> directive to invoke your Java class and method:
 
<pre>
 
<pre>
 
<screen name="findAndListInvoices">
 
<screen name="findAndListInvoices">
        <section>
+
  <section>
            <actions>
+
      <actions>
                <java location="com.opensourcestrategies.financials.invoice.InvoiceActions" invoke="findInvoices"/>
+
        <java location="com.opensourcestrategies.financials.invoice.InvoiceActions" invoke="findInvoices"/>
            </actions>
+
      </actions>
 
</pre>
 
</pre>
  

Latest revision as of 19:46, 26 October 2009

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);