Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // the package name corresponds to the module`s manual code folder
- // created above
- package org.rahmadnet.learning.AD_Callout;
- import javax.servlet.ServletException;
- import org.openbravo.utils.FormatUtilities;
- import org.openbravo.erpCommon.ad_callouts.SimpleCallout;
- import org.openbravo.base.secureApp.VariablesSecureApp;
- // classes required to retrieve product category data from the
- // database using the DAL
- import org.openbravo.dal.service.OBDal;
- import org.openbravo.model.common.plm.ProductCategory;
- // the name of the class corresponds to the filename that holds it
- // hence, modules/modules/org.rahmadnet.learning/src/org/rahmadnet/learning/ad_callouts/ProductConstructSearchKey.java.
- // The class must extend SimpleCallout
- public class ProductConstructSearchKey extends SimpleCallout {
- private static final long serialVersionUID = 1L;
- @Override
- protected void execute(CalloutInfo info) throws ServletException {
- // parse input parameters here; the names derive from the column
- // names of the teble prepended by inp and stripped of all
- // underscore characters; letters following the underscore character
- // are capitalized; this way the database column named
- // M_PRODUCT_CATEGORY_ID that is shown on a tab will become
- // inpmProductCategoryId html field
- String strProductName = info.getStringParameter("inpname", null);
- String strProductCategoryId = info.getStringParameter("inpmProductCategoryId", null);
- // inject the result into the response
- info.addResult("inpvalue", getConstructedKey(info.vars, strProductName, strProductCategoryId));
- }
- protected String getConstructedKey(VariablesSecureApp vars, String strProductName, String strProductCategoryId) {
- // Retrieve the product category name
- final ProductCategory productCategory = OBDal.getInstance().get(ProductCategory.class, strProductCategoryId);
- String strProductCategoryName = productCategory.getName();
- // construct full key
- String generatedSearchKey = FormatUtilities.replaceJS(strProductName.replaceAll(" ", " "))
- + "_" + strProductCategoryName.replaceAll(" ", " ");
- // return generated key
- return generatedSearchKey;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment