Pages

Wednesday, June 19, 2013

How To Use Smartclient VLayout In Openbravo

Smartclient VLayout In Openbravo

VLayout:

V layout represents as layout, in which is members such as form, buttons, grid and etc., are appear as vertically as shown below...


Now we will look in openbravo application, How VLayout reflects in it.

Lets take a look into example code below.

Now we will look in openbravo application, How VLayout reflects in it.

Lets take a look into example code below.

//define class of form prefix with your module prefix like XYZ_ , HGN_ and etc.,
//i used MRP as my prefix..
isc.defineClass('MRP_TimeTable', isc.VLayout);
//here i am adding properties for that class as follows..
isc.MRP_TimeTable.addProperties({
//here isSameTab function is used to open single window. If you try to open one //more time same window it will redirect to same window.
   isSameTab: function (viewId, params) {
       return viewId === 'MRP_TimeTable';
   },
   getBookMarkParams: function () {
       var result = {};
       result.viewId = 'MRP_TimeTable';
       return result;
   },
//here initWidget function having required information for a form.
//We can also use createWindowContents function instead of this.
   initWidget: function () {
//here we are creating a form item which represents as start date input.
       this.startdate = isc.DynamicForm.create({
           ID: "startdateid",
           titleOrientation: 'left',
           width: 250,
           autoDraw: true,
           fields: [{
               name: "classDate",
               title: "From Date",
               hasDefaultValue: true,
               type: '_id_15',
               required: true
           }],
           click: function () {
               this.Super('click', arguments);
           }
       });
//here we are creating a form item which represents as end date input.
       this.enddater = isc.DynamicForm.create({
           ID: "enddaterid",
           titleOrientation: 'left',
           width: 250,
           autoDraw: true,
           fields: [{
               name: "toclassDate",
               title: "To Date",
               hasDefaultValue: true,
               type: '_id_15',
               required: true
           }],
           click: function () {
               this.Super('click', arguments);
           }
       });
//here we are taking Vlayout so that we can add our components to that layout vertically.
       this.TotalLayout = isc.VLayout.create({
           dragAppearance: "target",
           overflow: "hidden",
           canDragResize: true,
           resizeFrom: ["L", "R"],
           layoutMargin: 20,
           membersMargin: 30,
           minWidth: 100,
           minHeight: 50,
           members: [
               this.startdate,
               this.enddater
           ]
       });
//here we are adding layout to form as whole...
       this.addMember(this.TotalLayout);
       this.Super('initWidget', arguments);
   },
   // this view does not have a help view
   getHelpView: function () {
       return;
   }
});

Here we need to create few folders such as below..

Create "web" folder in your module add one more folder with your package name like "com.yoursite.com" and then "js" folder then copy the  "Example.js" file into it. the path must be look like this   "web/com.yoursite.com/js/Example.js".

After developing this script lets give a name such as "Example.js" add this in openbravo.

Go to System admin and navigate to Application dictionary find View Implementation window, then add your script using defined class name in our case MRP_TimeTable, it may differ in your case be careful..
Then navigate Menu and add it to menu so that you can view your designed form.
Now we need to develop one more java file so that we can interact with our form.

Here we are going to assign our script to application so that it will recognize our smartclient form. Code as shown below.

package com.yoursite.com;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Collections;
import javax.enterprise.context.ApplicationScoped;
import org.openbravo.client.kernel.BaseComponentProvider;
import org.openbravo.client.kernel.Component;
import org.openbravo.client.kernel.ComponentProvider;
import org.openbravo.client.kernel.KernelConstants;
import org.openbravo.client.myob.MyOpenbravoWidgetComponent;
import org.openbravo.client.myob.MyOpenbravoComponent;
@ApplicationScoped
@ComponentProvider.Qualifier(MyExampleComponentProvider.COMPONENT_TYPE)
public class MyExampleComponentProvider extends BaseComponentProvider {
  public static final String COMPONENT_TYPE = "MRP_EXAMPLE";
  @Override
  public Component getComponent(String componentId, Map<String, Object> parameters) {
    throw new IllegalArgumentException("Component id " + componentId + " not supported.");
  }
  @Override
  public List<ComponentResource> getGlobalComponentResources() {
    final List<ComponentResource> globalResources = new ArrayList<ComponentResource>();

globalResources.add(createStaticResource(
        "web/com.yoursite.com/js/Example.js", false));
    return globalResources;
  }
  @Override
  public List<String> getTestResources() {
    return Collections.emptyList();
  }
}

Please comment for more explanation for above code only.. :)

How To Use Smartclient HLayout In Openbravo

Smartclient HLayout In Openbravo

HLayout:

H layout represents as layout, in which is members such as form, buttons, grid and etc., are appear as horizontally as shown below...


Now we will look in openbravo application, How HLayout reflects in it.

Lets take a look into example code below.

Now we will look in openbravo application, How HLayout reflects in it.

Lets take a look into example code below.

//define class of form prefix with your module prefix like XYZ_ , HGN_ and etc.,
//i used MRP as my prefix..
isc.defineClass('MRP_TimeTable', isc.HLayout);
//here i am adding properties for that class as follows..
isc.MRP_TimeTable.addProperties({
//here isSameTab function is used to open single window. If you try to open one //more time same window it will redirect to same window.
   isSameTab: function (viewId, params) {
       return viewId === 'MRP_TimeTable';
   },
   getBookMarkParams: function () {
       var result = {};
       result.viewId = 'MRP_TimeTable';
       return result;
   },
//here initWidget function having required information for a form.
//We can also use createWindowContents function instead of this.
   initWidget: function () {
//here we are creating a form item which represents as start date input.
       this.startdate = isc.DynamicForm.create({
           ID: "startdateid",
           titleOrientation: 'left',
           width: 250,
           autoDraw: true,
           fields: [{
               name: "classDate",
               title: "From Date",
               hasDefaultValue: true,
               type: '_id_15',
               required: true
           }],
           click: function () {
               this.Super('click', arguments);
           }
       });
//here we are creating a form item which represents as end date input.
       this.enddater = isc.DynamicForm.create({
           ID: "enddaterid",
           titleOrientation: 'left',
           width: 250,
           autoDraw: true,
           fields: [{
               name: "toclassDate",
               title: "To Date",
               hasDefaultValue: true,
               type: '_id_15',
               required: true
           }],
           click: function () {
               this.Super('click', arguments);
           }
       });
//here we are taking Hlayout so that we can add our components to that layout horizontally.
       this.TotalLayout = isc.HLayout.create({
           dragAppearance: "target",
           overflow: "hidden",
           canDragResize: true,
           resizeFrom: ["L", "R"],
           layoutMargin: 20,
           membersMargin: 30,
           minWidth: 100,
           minHeight: 50,
           members: [
               this.startdate,
               this.enddater
           ]
       });
//here we are adding layout to form as whole...
       this.addMember(this.TotalLayout);
       this.Super('initWidget', arguments);
   },
   // this view does not have a help view
   getHelpView: function () {
       return;
   }
});

Here we need to create few folders such as below..

Create "web" folder in your module add one more folder with your package name like "com.yoursite.com" and then "js" folder then copy the  "Example.js" file into it. the path must be look like this   "web/com.yoursite.com/js/Example.js".

After developing this script lets give a name such as "Example.js" add this in openbravo.

Go to System admin and navigate to Application dictionary find View Implementation window, then add your script using defined class name in our case MRP_TimeTable, it may differ in your case be careful..
Then navigate Menu and add it to menu so that you can view your designed form.
Now we need to develop one more java file so that we can interact with our form.

Here we are going to assign our script to application so that it will recognize our smartclient form. Code as shown below.

package com.yoursite.com;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Collections;
import javax.enterprise.context.ApplicationScoped;
import org.openbravo.client.kernel.BaseComponentProvider;
import org.openbravo.client.kernel.Component;
import org.openbravo.client.kernel.ComponentProvider;
import org.openbravo.client.kernel.KernelConstants;
import org.openbravo.client.myob.MyOpenbravoWidgetComponent;
import org.openbravo.client.myob.MyOpenbravoComponent;
@ApplicationScoped
@ComponentProvider.Qualifier(MyExampleComponentProvider.COMPONENT_TYPE)
public class MyExampleComponentProvider extends BaseComponentProvider {
  public static final String COMPONENT_TYPE = "MRP_EXAMPLE";
  @Override
  public Component getComponent(String componentId, Map<String, Object> parameters) {
    throw new IllegalArgumentException("Component id " + componentId + " not supported.");
  }
  @Override
  public List<ComponentResource> getGlobalComponentResources() {
    final List<ComponentResource> globalResources = new ArrayList<ComponentResource>();
 globalResources.add(createStaticResource(
        "web/com.yoursite.com/js/Example.js", false));
    return globalResources;
  }
  @Override
  public List<String> getTestResources() {
    return Collections.emptyList();
  }
}

Please comment for more explanation for above code only.. :)

How To Use Smartclient Layouts In Openbravo

Smart Client Layouts In Openbravo

Layouts: 

Layout is represent web page structure style. Layouts are of two kind VLayout and HLayout in smart client.
VLayout is represent vertical layout where members are arranged vertically(side by side).
HLayout is represent horizontal layout where members are arranged horizontally.

Layout  Class (in Smartclient):

Layout class is a subclass of Canvas that automatically arranges other Canvases according to a layout policy.

A Layout manages a set of "member" Canvases initialized via the "members" property. Layouts can have both "members", which are managed by the Layout, and normal Canvas children, which are not managed. 

Rather than using the Layout class directly, use the HLayout, VLayout, HStack and VStack classes, which are subclasses of Layout preconfigured for horizontal or vertical stacking, with the "fill" (VLayout) or "none" (VStack) policies already set. 

In Openbravo there is no difference in usage, we can use every method of layout class in it.

From above we have an idea about Layouts. For more information about layouts please look into HLayout and VLayout articles in this blog.

Example Code for Layout:

isc.defineClass('Ob_exmplelayout', isc.VLayout);

isc.Ob_exmplelayout.addProperties({
    ID: 'ifvw',
    initWidget: function () {
        this.hegly = isc.HLayout.create({
            width: "100%",
            height: "100%",
            members: [
                isc.Label.create({
                    contents: "Navigation Content",
                    align: "center",
                    overflow: "hidden",
                    width: "30%",
                    showResizeBar: true,
                    border: "1px solid blue"
                }),
                isc.VLayout.create({
                    width: "70%",
                    members: [
                        isc.Label.create({
                            contents: "Header Listing",
                            align: "center",
                            overflow: "hidden",
                            height: "30%",
                            showResizeBar: true,
                            border: "1px solid blue"
                        }),
                        isc.Label.create({
                            contents: "Body Details",
                            align: "center",
                            overflow: "hidden",
                            height: "70%",
                            border: "1px solid blue"
                        })
                    ]
                })
            ]
        });

        this.addMember(this.hegly);
        this.Super('initWidget', arguments);
    }
});

Example View for Layout:



Any issues related to this please comment it.

Tuesday, May 21, 2013

Developing Manual Window In Openbravo Using Smartclient



Developing Manual Windows In Openbravo Using Smartclient

Openbravo ERP using smart client technology to develop widows. I decided to give more information this. So that developer can reduce efforts for finding help. Hope fully this blog will give you more information about Openbravo and Smartclient scenario. This blog will give you basic knowledge of smart client.

You can learn following things in this blog.
  • Layouts
  • VLayout
  • HLayout
  • Text Fields
  • Buttons
  • Alerts
  • Pop-up Windows
  • Banners
  • Validations
  • Messages
  • Field Dependents
  • Selector Dependents
  • Grid Dependents
  • Selector - Grid Dependents
  • Criteria
  • Grid Creation
  • Grid Properties
  • Check Boxes
  • Radio Buttons
  • Handlers
  • Remote Call Manager Usage
  • Callback Usage
  • Empty Grid Messages
  • A Complete Example with full features.
For more information about above concepts search in my blog.


Tuesday, April 23, 2013

Legacy Data Inserting Into Openbravo Using Initial Data Process

Initial Data Process :

The import loader process is used to load data into the openbravo windows from input files. Openbravo has provided the options to load product, business partner, etc., Now we have the option of creating import process for our own modules with a simple java file.

Right now this process reads data from csv file(The Input format is parsed using the file IdlServiceJava.java file). This can also be extended to read input from other formats by creating a service file similar to IdlServiceJava. 

To try this out you need the Professional Subscription License. And you need to add following two modules. For that go to General Setup -> Application -> Module Management -> Add Modules.

Search and install the following modules.
  • Initial Data Load.
  • Initial Data Load Extension for Java.

 Developing Java File:

/*
 ************************************************************************************
 * Copyright (C) 2009-2010 Openbravo S.L.U.
 * Licensed under the Openbravo Commercial License version 1.0
 * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
 * or in the legal folder of this module distribution.
 ************************************************************************************
 */

package org.ram.www.intial;

import java.lang.*;
import java.util.*;
import org.openbravo.idl.proc.Parameter;
import org.openbravo.idl.proc.Validator;
import org.openbravo.dal.service.OBQuery;
import org.openbravo.base.exception.OBException;
import org.openbravo.base.provider.OBProvider;
import org.openbravo.base.structure.BaseOBObject;
import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBDal;
import org.openbravo.erpCommon.utility.Utility;
import org.openbravo.idl.proc.DALUtils;
import org.openbravo.idl.proc.Value;
import org.openbravo.model.common.currency.Currency;
import org.openbravo.model.common.uom.UOM;
import org.openbravo.module.idljava.proc.IdlServiceJava;
import org.openbravo.base.model.ModelProvider;

import org.xyz.www.cscrmstat;

/**
 * Converts Excel Data in to Database Records @Initial Data Load
 *
 * @author Hsakarpmar
 */

public class StatusList extends IdlServiceJava {

@Override
public String getEntityName() {
return "CS_CRM_Status";
}
 
@Override
public Parameter[] getParameters() {
return new Parameter[] {
new Parameter("sno", Parameter.STRING),
new Parameter("status", Parameter.STRING)
};
}

@Override
protected Object[] validateProcess(Validator validator, String... values) throws Exception {
System.out.println("validate process");
        validator.checkNotNull(validator.checkString(values[1], 32), "status");
        System.out.println("after validated method");          
        return values;
}

@Override
public BaseOBObject internalProcess(Object... values) throws Exception {
  System.out.println("internal process method method");
  return createcscrmstat((String)values[0],(String)values[1]);
}

public BaseOBObject createcscrmstat(final String sno,final String status)throws Exception {
 System.out.println("control in results method");
 cscrmstat dummy= findDALInstance(false, cscrmstat.class, new Value("commercialName", status));
   
   if(dummy!= null){
    System.out.println(dummy);
    System.out.println("if condition  cscrmstat.class ");
    }   
else{
    dummy = OBProvider.getInstance().get(cscrmstat.class);
    System.out.println(dummy);
    dummy.setCommercialName(status);
     }
    OBDal.getInstance().save(dummy);
    OBDal.getInstance().flush();
    OBDal.getInstance().commitAndClose();
    return dummy;
}
}

You can place it where ever you want to, but just be careful to provide the proper Java package name. Also, ensure that you place the Java file in the correct module, so that it is packaged, when you run an "export.database". 

------------------------------------------------- Code Explanation ------------------------------------------------
public Parameter[] getParameters() {
return new Parameter[] {
new Parameter("sno", Parameter.STRING),
new Parameter("status", Parameter.STRING)
};
}

The parameters in the above method should be in the same order as they appear in the input file. However, the parameter names used in the method need not be the same as the column header in the input file. 


public BaseOBObject createcscrmstat(final String sno,final String status)throws Exception {
 System.out.println("control in results method");
 cscrmstat dummy= findDALInstance(false, cscrmstat.class, new Value("commercialName", status));
   
   if(dummy!= null){
    System.out.println(dummy);
    System.out.println("if condition  cscrmstat.class ");
    }   
else{
    dummy = OBProvider.getInstance().get(cscrmstat.class);
    System.out.println(dummy);
    dummy.setCommercialName(status);
     }
    OBDal.getInstance().save(dummy);
    OBDal.getInstance().flush();
    OBDal.getInstance().commitAndClose();
    return dummy;
}
}


The createcscrmstat() method inserts values into the desired table using OBProvider. The internalProcess() method, which is inherited from IdlServiceJava class, is used to call the appropriate method with appropriate parameters.
------------------------------------------------------------------------------------------------------------------------- 

Define the Process:

After developing your code. need to register. Please follow as below,
  • Go to Master Data Management -> Initial Data Load -> Setup -> Entity Default Value
  • Register your Java file here as shown in the screen shot.

Pay special attention on the class name while adding the entity default value.
  • Import the data using import window
  • Go to Master Data Management -> Initial Data Load -> Process -> Import
  • Choose the input file
  • Choose the entity as Master Status List.

Validate the input file. If the file has invalid data, it will show the invalid data in the log. 

 
Once the input values are validated, the data can be loaded into the actual table by clicking on the process.If there are any issues while processing the input data, appropriate messages will be logged in the message box provided under the Log header in the import screen.



After Successfully Processed  imports check out the window (Table in which your inserting).

For more clarification and issues please comment below.

Monday, April 22, 2013

Openbravo Setup and Configuration In Windows







Hi Technops, 

This article is for complete installation and configuration of Openbravo in Windows environment.

Environment Requirements:-



1.Hardware Requirements
3GB RAM,80GB Hard Disk
2.Operating System
Windows Server
3. Browsers
Mozilla Firefox, Internet Explorer
4. Database
Oracle 9i to 11g
5. Application Server
Tomcat
6. Web Service
 Apache
7. Development Tool Kit
JAVA
8. ERP
Open bravo















I am covering following Concepts:
 
1.       Installation of Databases (Oracle and PostgreSQL).

2.       Installation of JAVA.

3.       Installation of Tomcat.

4.       Installation of Apache.

5.       Installation of Openbravo
 
 
1.    Installation of Oracle 11g Database
      
       Now i am going to use Oracle 11g as my database and installing in Windows environment.
       Run Oracle 11g setup file, you will get following screen. 



When we click on setup icon above screen appears. Select basic installation and give the Database name and PACE (In this case).


Click on next after checking the first option in the window.

  
Click Next.

  
Click Install.


    Installation will complete in this step.
    After this give password for system in Password management Window .
    Ex:-In this case it is pace.
  

Database User Creation:-

      -Connect to  Sqlplus  in CMD
      -Enter Username: openbravo (In This case).
      -Enter Password: password (In This case).
      -SQL: create user mybravo Identified by mybravo
      -SQL: grant all privileges to mybravo
 

    2. Installation of JAVA

Install JAVA executable file and set the environment variable.
 

Modify Path system variable for JAVA:
E:\app\Administrator\product\11.1.0\db_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.6.0_18\bin;



3.    Installation of Tomcat
 
Copy Tomcat and Apache core files into Openbravo folder.

Tomcat environment variable setup
My Computer PropertiesàAdvancedàEnvironment Variables
Setup CATALINA_BASE, CATALINA_HOME, and CATALINA_OPTS under system Variables.


Modify Path system variable for Tomcat:
E:\app\Administrator\product\11.1.0\db_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.6.0_18\bin;E:\open bravo\Tomcat\bin;


To check the status of tomcat installation start the tomcat service and please go to the below link:
http:\\localhost:8080


4. Installation of Apache

Apache Environment Variables Setup
My Computer PropertiesàAdvancedàEnvironment Variables
Setup ANT_HOME, ANT_OPTS under system Variables.

Modify Path system variable for Apache:
E:\app\Administrator\product\11.1.0\db_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\ProgramFiles\Java\jdk1.6.0_18\bin;E:\openbravo\Tomcat\bin;E:\openbravo\Apache-Ant\bin; 



5. Installation of Openbravo.

Copy the delivered Code Tree in the open bravo folder.

In Command Prompt E:\.
(Here we are mentioning E: drive because installation of openbravo is in E drive)

-Using command prompt go to your installed folder. (E:\openbravo\OpenbravoERP-3.0\ )
Then run "ant setup" command in command prompt.


 -Ant setup is to generate openbravo install file and the path where it is generated is (E:\openbravo\OpenbravoERP-3.0\config).
   
Run the .exe file the setup page activates, click on next

 

Check I accept and click on next.



Click on Next.



Create a Folder First in the code and then give the path for Attachment Directory below.


Click on Next.



Check the Database on which the openbravo is installed in this case oracle.





      Change the SID and password accordingly and click on next

 
Click on Next.

 
   Click on Next.



Click on Next.

Click on Next






Click on Finish.



      After that go to command prompt give the command E:\openbravo\ant install.source:

-This is to install openbravo ERP and database.(This will take some time).
Installation is complete with this step.
  
Start the Tomcat services.
 
-  Give the path in the browser: Ex: http://localhost:8080/openbravo/security/Menu.html.

-  Once the open bravo page is up activate the instance in general setup by giving the golden key.

-  To add a module or OBX: General SetupàApplicationàModule Management. In that click Add modules and give the path of the OBX file and install it. After installing check the option rebuild now for installed module .
   Ex:smartcs.

-  Rebuild the System. If in case of any error during build process run the command:
“ant update. Database compile.complete-Dforce=yes”.

After whole process done successfully go to  "http://localhost:8080/openbravo"
Then enter User Name as Openbravo and password as openbravo. Once you are login into Openbravo successfully our installation and configuration is done.

For any more issues and information, please comment below.