Apache OfBiz Cookbook by Ruth Hoffman

** The HttpServletRequest and HttpServletResponse variable may be named anything. Convention has them labeled as "request" and "response" respectively. An OFBiz Event may have many return values, where each value represents a directive instructing the Controller Servlet on what to do upon method return. info Java Development There may be many OFBiz Events with the same method name and package declaration on the CLASSPATH. In that case, OFBiz will use the last one found and pass control to that method.

ReturnSuccess(); return result; } Where the method declaration has the following required modifiers: Java method modifiers Return type "public", "static" Map Method name Identical to the Service name as configured in the Service's configuration file Parameter list DispatchContext dctx, Map context * * The DispatchContext and context objects may be named anything. Convention has them named as dctx and context respectively. info Chapter 2 For a Service to be consumed, it must be "registered" with OFBiz and have a "Service definition".

How to do it... The follow example demonstrates calling the sendMail Service from an OFBiz Event. Calling the sendMail Service from another Java program such as a servlet or Service works the same way. Note: The following program is for demonstration purposes only. It will compile and run within an OFBiz instance. However, much of the logic is hardcoded. This is intentional. Only enough code is shown to highlight the topic. You will need to add the proper import statements as they have been removed to conserve space.

Download PDF sample

Rated 4.00 of 5 – based on 24 votes