...
5.) Test service implemented using webtools --> Run Service option(https://localhost:8443/webtools/control/runService) or simply update simply update/add the service name/new service being called by your controller request to use this service instead and use add form in your app that you prepared earlier. By doing this your Add OfbizDemo form will call this java service. Find below to new service createOfbizDemoByJavaService
which will be called by your controller request.
|
...
To make sure this new service implementation is being executed, you can check this line in the console log that you have put in your code using Debug.log(....). For logging in OFBiz, you must always use Debug class methods in Java classes.
Console Log
|
...
|
...
import org.apache.ofbiz.entity.GenericEntityException; createOfbizDemo() { result = [:]; try { ofbizDemo = delegator.makeValue( "OfbizDemo" ); // Auto generating next sequence of ofbizDemoId primary key ofbizDemo.setNextSeqId(); // Setting up all non primary key field values from context map ofbizDemo.setNonPKFields(context); // Creating record in database for OfbizDemo entity for prepared value ofbizDemo = delegator.create(ofbizDemo); result.ofbizDemoId = ofbizDemo.ofbizDemoId; logInfo( "==========This is my first Groovy Service implementation in Apache OFBiz. OfbizDemo record " + "created successfully with ofbizDemoId: " +ofbizDemo.getString( "ofbizDemoId" )); } catch (GenericEntityException e) { logError(e.getMessage()); return error( "Error in creating record in OfbizDemo entity ........" ); } return result; } |
4.) Stop the server and re-start using"./gradlew ofbiz", this time we just need to load the new service definition, no explicit compilation is required as its a service implementation in Groovy.
5.) Test service implemented using webtools --> Run Service option(https://localhost:8443/webtools/control/runService) or simply update/add the service name/new service being called by your controller request to use this service instead and use add form in your app that you prepared earlier for testing. By doing this your Add OfbizDemo form will call this groovy service. Find below the new service createOfbizDemoByGroovyService which will be called by your controller request.
controller.xml
|
...
To make sure this new service implementation is being executed, you can check this line in console log that you have put in your code using Debug.log(....). For logging in OFBiz you must always use Debug class methods in Java classes.
|
...
|
3.) Stop and start the server by rebuilding it as we need to compile the Java event class that we have added in #1.
4.) Now to test the event you can simply change the AddOfbizDemo form target to read "createOfbizDemoEvent" and as its it's submitted now it will call your event.
...
Starting from here follow steps given:
1.) Add a new crud directory under the location $ OFBIZ_HOME/plugins/ofbizDemo/webapp/ofbizDemo/
2.) Add Add two Freemarker files at location $ OFBIZ_HOME/plugins/ofbizDemo/webapp/ofbizDemo/crud/AddOfbizDemo.ftl and ListOfbizDemo.ftl, as shown below:
...
|
4.) Add a new controller request and a new item for the OfbizDemo menu as:
controller.xml
...