Retrieving Parameters for DAL Process and Callouts in OpenbravoERP

In OpenbravoERP, when we write DAL Process, the first thing that we would need are the input parameters with which we can operate on the Window. By default there are some key parameters passed to the process bundle. They are:
1. Record ID
2. Tab Id
3. Client ID
4. Org ID
These values are presented to the user as key-value pairs. They can be retrieved as provided below:
String id=(String) bundle.getParams().get("TDS_Process_Pay_ID");
String id=(String) bundle.getParams().get("tabId");
The Catch here is that the key-value pairs are Case Sensitive. So the case of your name matters. But more often than not we cannot guess the case of our element variables. Instead of playing the guessing game you can use a very useful method provided in the same process bundle class, which is bundle.getParamsDefalated().This method returns all the process parameters that can be used in the process as a single string delimited by {[key1,value1]}. One example string that was retrieved is provided here.
Bundle {"map":{"entry":[{"string":["adOrgId",""]},{"string":["tabId","9EB442F0BD9141319FAF085EF30D7CC9"]},{"string":["TDS_Process_Pay_ID","FF8081812EB2DA4C012EB2DD8117001A"]},{"string":["adClientId",""]}]}}

Using this you can make sure you provide the right name to retrieve the process parameters.

                Callouts are a cool feature in Openbravo that helps us in defaulting fields and validating them at runtime. There is a simplecallout class defined in Openbravo using which we can extend and write our own callouts easily and effectively.For basics about developing callouts refer here. Even in callouts you have to retrieve the field's value that you want to operate upon and set in the same manner. More often I see people confusing themselves between the parameter for Callout and process. The input field is usually prefixed  by 'inp' and the variable names are camel cased.For eg if the database field name is 'first_name', the field can be retrieved using the following command,
String firstName = info.getStringParameter("inpfirstName",null);
And in case of Numeric fields, this command can be used.
BigDecimal noofbed = info.getBigDecimalParameter("inpnoOfBed");
And its easily a best practice to include logger so that you can record the status of the Process/Callout. You have to import theorg.apache.log4j.Logger for this purpose. The logger can be instantiated and used as follows:
private static Logger log = Logger.getLogger(TrialProgram.class);"Displaying Sample Information");


Popular posts from this blog

Changing Timezone in Postgresql, Ubuntu

Display Logic and read only logic In Openbravo

My 10 years in Application Development