<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_to_create_a_Java_Process</id>
	<title>How to create a Java Process - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_to_create_a_Java_Process"/>
	<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_Java_Process&amp;action=history"/>
	<updated>2026-04-06T20:09:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_Java_Process&amp;diff=226&amp;oldid=prev</id>
		<title>Wikiadmin: /* Add the process form to the menu */</title>
		<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_Java_Process&amp;diff=226&amp;oldid=prev"/>
		<updated>2018-10-15T13:09:08Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Add the process form to the menu&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 13:09, 15 October 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l138&quot; &gt;Line 138:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 138:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Image:obexapp_CreateProcessMenu.png|center|700px]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Image:obexapp_CreateProcessMenu.png|center|700px]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Build Step ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Build Step ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_Java_Process&amp;diff=221&amp;oldid=prev</id>
		<title>Wikiadmin: Created page with &quot;{{(!)|GUI for processes explained in this document is generated using 2.50 infrastructure and are kept for backwards compatibility. If you are working with '''3.0MP20''' or gr...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_Java_Process&amp;diff=221&amp;oldid=prev"/>
		<updated>2018-10-15T13:03:22Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{(!)|GUI for processes explained in this document is generated using 2.50 infrastructure and are kept for backwards compatibility. If you are working with &amp;#039;&amp;#039;&amp;#039;3.0MP20&amp;#039;&amp;#039;&amp;#039; or gr...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{(!)|GUI for processes explained in this document is generated using 2.50 infrastructure and are kept for backwards compatibility. If you are working with '''3.0MP20''' or greater, consider implementing a [[How_to_create_a_Standard_Process_Definition|Standard Process Definition]] instead.}}&lt;br /&gt;
&lt;br /&gt;
== How to create a Java Based Process ==&lt;br /&gt;
&lt;br /&gt;
Java processes are one of the mechanisms Openbravo provides to implement business logic. A java process can be a [[How_to_develop_a_DAL_background_process|background]] process or can have a user interface which allows entering parameters. In this howto we will discuss a java process supported with a user interface with parameters. &lt;br /&gt;
&lt;br /&gt;
This document discusses the Openbravo infrastructure for Java processes. For a generic description of java processes see this wiki page: [[Processes]].&lt;br /&gt;
&lt;br /&gt;
== Example Module ==&lt;br /&gt;
&lt;br /&gt;
This howto is supported by an example module which shows example of the code shown and discussed in this howto. &lt;br /&gt;
&lt;br /&gt;
The code of the example module can be downloaded from this mercurial repository: https://code.openbravo.com/erp/mods/org.openbravo.client.application.examples/&lt;br /&gt;
&lt;br /&gt;
The example module is available through the Central Repository (See 'Client Application Examples'), for more information see the [[Projects/ExamplesClientApplication|Examples Client Application]] project page.&lt;br /&gt;
&lt;br /&gt;
For your specific development you should create a new module. Please follow the [[How_To_Create_and_Package_a_Module | How to create and package a module]] section to create a new module.&lt;br /&gt;
&lt;br /&gt;
{{(!)|The example module also contains implementations of other howtos.}}&lt;br /&gt;
&lt;br /&gt;
== Development Steps ==&lt;br /&gt;
&lt;br /&gt;
The steps to create a java process supported by a user interface are:&lt;br /&gt;
# create a java class implementing the business logic&lt;br /&gt;
# enter a new record in 'Report and Process', defining the pattern, the java class (step 1) and the parameters&lt;br /&gt;
# add the new process to the menu&lt;br /&gt;
&lt;br /&gt;
=== Java class declaration ===&lt;br /&gt;
&lt;br /&gt;
First at all, take a look at the Java package in which the java class is defined, it must be included in the java package the module defines. The Java class implementing the process must implement the ''org.openbravo.scheduling.Process'' interface, this is done usually extending the class ''org.openbravo.service.db.DalBaseProcess'' that provides common code to use DAL in Processes. Extending this class there only needed to overwrite one method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 public void doExecute(ProcessBundle bundle) throws Exception;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method receives a ''ProcessBundle'', this bundle contains all the parameters for the process. When the process finishes it must add a result to this bundle, this result is an ''OBError'' instance that will be shown in the pop-up. For further explanations on messages read the [[Messages]] documentation.&lt;br /&gt;
&lt;br /&gt;
Let's explain it using a little example (this class and its parameters are used in the process definition further down in this howto):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;public class ExampleJavaProcess extends DalBaseProcess {&lt;br /&gt;
&lt;br /&gt;
  public void doExecute(ProcessBundle bundle) throws Exception {&lt;br /&gt;
    try {&lt;br /&gt;
&lt;br /&gt;
      // retrieve the parameters from the bundle&lt;br /&gt;
      final String bPartnerId = (String) bundle.getParams().get(&amp;quot;cBpartnerId&amp;quot;);&lt;br /&gt;
      final String organizationId = (String) bundle.getParams().get(&amp;quot;adOrgId&amp;quot;);&lt;br /&gt;
      final String tabId = (String) bundle.getParams().get(&amp;quot;tabId&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
      final String myString = (String) bundle.getParams().get(&amp;quot;mystring&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
      // implement your process here&lt;br /&gt;
&lt;br /&gt;
      // Show a result&lt;br /&gt;
      final StringBuilder sb = new StringBuilder();&lt;br /&gt;
      sb.append(&amp;quot;Read information:&amp;lt;br/&amp;gt;&amp;quot;);&lt;br /&gt;
      if (bPartnerId != null) {&lt;br /&gt;
        final BusinessPartner bPartner = OBDal.getInstance().get(BusinessPartner.class, bPartnerId);&lt;br /&gt;
        sb.append(&amp;quot;Business Partner: &amp;quot; + bPartner.getIdentifier() + &amp;quot;&amp;lt;br/&amp;gt;&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      if (organizationId != null) {&lt;br /&gt;
        final Organization organization = OBDal.getInstance().get(Organization.class,&lt;br /&gt;
            organizationId);&lt;br /&gt;
        sb.append(&amp;quot;Organization: &amp;quot; + organization.getIdentifier() + &amp;quot;&amp;lt;br/&amp;gt;&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      sb.append(&amp;quot;MyString: &amp;quot; + myString + &amp;quot;&amp;lt;br/&amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
      // OBError is also used for successful results&lt;br /&gt;
      final OBError msg = new OBError();&lt;br /&gt;
      msg.setType(&amp;quot;Success&amp;quot;);&lt;br /&gt;
      msg.setTitle(&amp;quot;Read parameters!&amp;quot;);&lt;br /&gt;
      msg.setMessage(sb.toString());&lt;br /&gt;
&lt;br /&gt;
      bundle.setResult(msg);&lt;br /&gt;
&lt;br /&gt;
    } catch (final Exception e) {&lt;br /&gt;
      e.printStackTrace(System.err);&lt;br /&gt;
      final OBError msg = new OBError();&lt;br /&gt;
      msg.setType(&amp;quot;Error&amp;quot;);&lt;br /&gt;
      msg.setMessage(e.getMessage());&lt;br /&gt;
      msg.setTitle(&amp;quot;Error occurred&amp;quot;);&lt;br /&gt;
      bundle.setResult(msg);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example a parameter named ''cBpartnerId'' is expected. It is read by the following line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  final String bPartnerId = (String) bundle.getParams().get(&amp;quot;cBpartnerId&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The name of the parameter to use in the get method depends on the db column name entered in the parameters of the process (see below).&lt;br /&gt;
&lt;br /&gt;
Once the process is finished a new OBError is created to handle the message and it is added as result to the ''bundle''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  bundle.setResult(msg);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Defining the user interface ===&lt;br /&gt;
&lt;br /&gt;
The java class above shows how to implement the backend business logic. This section explains how to define a user interface which makes it possible to enter parameters.&lt;br /&gt;
&lt;br /&gt;
To define process records one should normally be a System Admin.&lt;br /&gt;
&lt;br /&gt;
The first step is to create a process record, go to Application Dictionary &amp;gt; Report and Process (or easier use quick launch and goto the Report and Process window directly). Create a new process record like shown in the example below. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:obexapp_CreateProcessRecord.png|center|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main thing here is to select UI Pattern: Standard. Further below it is explained what UI Pattern Manual means.&lt;br /&gt;
&lt;br /&gt;
Then create a child record in Process Class and enter the fully qualified class name of the java class you created below. &lt;br /&gt;
&lt;br /&gt;
'''Important: check the default flag! If this is not done then a compile error will occur in the next build step.'''&lt;br /&gt;
&lt;br /&gt;
Now the parameters of the process need to be defined. Or more exactly their type and visualization. This is done through the Parameter child tab of the process. The example has three parameters: business partner, organization and a string. The screenshots below visualize their settings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:obexapp_CreateProcessParam1.png|center|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:obexapp_CreateProcessParam2.png|center|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some notes:&lt;br /&gt;
* the db column name does not have to be a real database column, the value of this field is used to generate the parameter name used in the source code. It is adviced to use simple names without underscores (that's the simplest).&lt;br /&gt;
* the application element defines the label in the user interface&lt;br /&gt;
* the 2 reference fields denote the type of the field&lt;br /&gt;
&lt;br /&gt;
=== Add the process form to the menu ===&lt;br /&gt;
&lt;br /&gt;
To make the process window available to the user it has to be added to a menu. This is done like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:obexapp_CreateProcessMenu.png|center|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Build Step ===&lt;br /&gt;
&lt;br /&gt;
After creating the process user interface, stop the application and type in the following command in a console (within the development project):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;ant compile -Dtab=XXX&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generate the process window.&lt;br /&gt;
&lt;br /&gt;
If you have eclipse running, refresh the development project.&lt;br /&gt;
&lt;br /&gt;
Then start the application and login with the client administrator (normally the system administrator will not have access).&lt;br /&gt;
&lt;br /&gt;
== The result ==&lt;br /&gt;
&lt;br /&gt;
Goto quick launch and enter the name of the new process or find it in the correct location in the menu.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:obexapp_CreateProcessResult1.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enter some values and press ok. The result:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:obexapp_CreateProcessResult2.png|center]]&lt;br /&gt;
&lt;br /&gt;
== Variant: Running the process from a button in another window ==&lt;br /&gt;
&lt;br /&gt;
A process can also be run from another window (from a button). A button in an Openbravo window needs a (dummy) database column. To accomplish this do the following:&lt;br /&gt;
* add a column to the table shown in the window&lt;br /&gt;
* give the column the button reference and select the process &lt;br /&gt;
* create a window, tab and field for the column&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:obexapp_CreateProcessColumn.png|center|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This will show a button on the right in the window.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:obexapp_CreateProcessColumnDisplay.png|center|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When a process is run from another window then the ProcessBundle will contain extra default parameters which can be useful:&lt;br /&gt;
* recordID: the id of the selected record&lt;br /&gt;
* tabId: the id of the tab from which the process was called&lt;br /&gt;
&lt;br /&gt;
== Variant: Manual UI Pattern ==&lt;br /&gt;
&lt;br /&gt;
The difference between ''Standard'' and ''Manual'' ''UI Pattern'' is that no pop-up is automatically generated for ''Manual UI'' pattern processes, in this case the pop-up must be manually generated by the class implementing the process.&lt;br /&gt;
&lt;br /&gt;
As shown above, java classes for standard processes implement the &lt;br /&gt;
Manual processes are implemented by a Java class implementing the ''org.openbravo.scheduling.Process'' interface. For manual processes the java class needs to extend ''org.openbravo.base.secureApp.HttpSecureAppServlet'', this is a standard servlet that generates the pop-up.&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
</feed>