acq:developers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
acq:developers [2007/12/09 21:42] – art | acq:developers [2007/12/09 21:48] – art | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Acquisitions/ | ||
+ | OFBiz/ | ||
+ | |||
+ | We have made some changes to the layout of OFBiz, nothing complex in a technical sense, but it is well worth touching base with us before embarking on a developer' | ||
+ | |||
+ | In general, the main objects of most changes do not require a restart: | ||
+ | |||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * Screens XML files | ||
+ | * Forms XML files | ||
+ | * controller XML file | ||
+ | |||
+ | There is a cache that often needs to be cleared in //Web Tools// when making modifications, | ||
+ | |||
+ | ====Up close: modifying the Purchase Order screen==== | ||
+ | |||
+ | OFBiz applications are made up of many small pieces. Although some developers use OFBiz as a general purpose framework, its value is clearly far more as a ready source of financial functions and data models (see [[http:// | ||
+ | |||
+ | The example that might be the most helpful is both intricate (in terms of layout) and trivial (in terms of actual code), and that is using [[http:// | ||
+ | |||
+ | {{: | ||
+ | |||
+ | As you may have guessed, the " | ||
+ | |||
+ | https:// | ||
+ | |||
+ | We will ignore the hostname and port, and focus on the rest of the url: | ||
+ | |||
+ | / | ||
+ | |||
+ | The first part of the address is the // | ||
+ | |||
+ | {{: | ||
+ | |||
+ | And, sure enough, in this file, we find the entry point for // | ||
+ | |||
+ | <webapp name=" | ||
+ | title=" | ||
+ | server=" | ||
+ | location=" | ||
+ | base-permission=" | ||
+ | mount-point="/ | ||
+ | |||
+ | This tells us that the building blocks of // | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ====The Role of the Controller==== | ||
+ | |||
+ | The file that represents the switchboard for URL requests is // | ||
+ | |||
+ | < | ||
+ | < | ||
+ | Handles setting the currency, agreement and shipment dates of an order. | ||
+ | </ | ||
+ | < | ||
+ | <event type=" | ||
+ | invoke=" | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | This tells us a bit about what this request is responsible for, and what action should take place. In this case, a java action is invoked (// | ||
+ | |||
+ | < | ||
+ | < | ||
+ | <event type=" | ||
+ | invoke=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | Again, more java plumbing is invoked, but this time there are 4 possible outcomes. It is possible to glean the jumping off point from the code, but the // | ||
+ | |||
+ | [ UtilXml.java: | ||
+ | [ConfigXMLReader.java: | ||
+ | [ConfigXMLReader.java: | ||
+ | [ConfigXMLReader.java: | ||
+ | [ConfigXMLReader.java: | ||
+ | [ UtilXml.java: | ||
+ | [ ScreenFactory.java: | ||
+ | [ UtilXml.java: | ||
+ | [ ScreenFactory.java: | ||
+ | |||
+ | This is where things start getting interesting, | ||
+ | |||
+ | <screen name=" | ||
+ | < | ||
+ | < | ||
+ | <set field=" | ||
+ | <set field=" | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | location=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | In this case, // | ||
+ | |||
+ | <div class=" | ||
+ | <div class=" | ||
+ | <div class=' | ||
+ | </ | ||
+ | <div class=" | ||
+ | <#if (shoppingCartSize > 0)> | ||
+ | <#if hidetoplinks? | ||
+ | < | ||
+ | ${uiLabelMap.EcommerceViewCart}</ | ||
+ | <a href="< | ||
+ | ${uiLabelMap.EcommerceCheckout} | ||
+ | </a> | ||
+ | </ | ||
+ | </# | ||
+ | </# | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====Launching from a Button==== | ||
+ | |||
+ | To add an Evergreen lookup, we modify the // | ||
+ | |||
+ | <a href=" | ||
+ | class=" | ||
+ | </a> | ||
+ | |||
+ | Note the use of // | ||
+ | |||
+ | function quicklookupevergreen_popup(element) { | ||
+ | target = element; | ||
+ | var searchTerm = element.value; | ||
+ | var obj_lookupwindow = window.open('/ | ||
+ | + searchTerm,' | ||
+ | ' | ||
+ | left=' | ||
+ | obj_lookupwindow.opener = window; | ||
+ | obj_lookupwindow.focus(); | ||
+ | } | ||
+ | |||
+ | Once again, the URL invoked is the key construct in making something useful happen, in this case: | ||
+ | |||
+ | / | ||
+ | |||
+ | Thanks to the wizardry of [[http:// | ||
+ | |||
+ | {{: | ||
+ | |||
+ | We would probably want to transfer much more information to // | ||
+ | |||
+ | / | ||
+ | |||
+ | Once again, the ofbiz-component.xml file reveals the entry point for // | ||
+ | |||
+ | <webapp name=" | ||
+ | title=" | ||
+ | server=" | ||
+ | location=" | ||
+ | base-permission=" | ||
+ | mount-point="/ | ||
+ | |||
+ | No surprises here, and the // | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | and, in turn, the view is contained inside an XML file called // | ||
+ | |||
+ | < | ||
+ | page=" | ||
+ | |||
+ | Note the syntax, this indicates that section we want in // | ||
+ | |||
+ | <screen name=" | ||
+ | < | ||
+ | < | ||
+ | <set field=" | ||
+ | <set field=" | ||
+ | <set field=" | ||
+ | <set field=" | ||
+ | <script location=" | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | location=" | ||
+ | <!-- include the duplicate product form template --> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | There is a **lot** going on here, but our addition is quite simple: | ||
+ | |||
+ | <script location=" | ||
+ | |||
+ | This syntax indicates that we want to run a beanshell script called // | ||
+ | |||
+ | import org.ofbiz.base.util.*; | ||
+ | import org.ofbiz.entity.*; | ||
+ | // simple for now, these variables could be passed directly | ||
+ | recordId = request.getParameter(" | ||
+ | title = request.getParameter(" | ||
+ | if (recordId != null) | ||
+ | context.put(" | ||
+ | if (title != null) | ||
+ | context.put(" | ||
+ | |||
+ | There are several options for the kind of scripts that can be invoked, but beanshell has the advantage that it can leverage the Java APIs. Not very significant in this example, yet this often very handy for using Java for some quick heavy lifting while retaining a light scripting layer to pull the pieces together. In this case, the resulting form should show the values we transferred from the catalogue. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | This is a trivial example, but it hopefully illustrates one general approach to modifying OFBiz/ |
acq/developers.txt · Last modified: 2022/02/10 13:34 by 127.0.0.1