Openbravo Forum End of Life Notice

Dear Openbravo Forum User,

Because of continued very low usage we decided to stop the forums on 31st of August 2017

In case of questions: webmaster "at"

Event Handler


Giovanni Garofalo

Posts: 5

Joined: Wed Mar 30, 2011 8:36 am

Post Fri Jul 08, 2011 4:46 pm

Event Handler


I'm working with OB 3.00 MP0
I need to create an Event Handler on Work Requirement windows,
In onSave Event I need to insert some records into a new sub-tab.

I followed this how-to ... nt_handler ,
but in my case it doesn't works correctly.
It doesn't saves any records in sub-tab, but it saves only the Work Requirement record.

My code is:

public void onSave(@Observes EntityNewEvent event) {
if (!isValidEvent(event)) {
final Entity workRequirementEntity = ModelProvider.getInstance().getEntity(
final WorkRequirement workRequirement = (WorkRequirement) event.getTargetInstance();
ProcessPlan processPlan = workRequirement.getProcessPlan();
Date wrCreationDate = workRequirement.getWRCreationDate();
ProcessPlanDAO ppDao = ProcessPlanDAO.singleton();
List<OperationProduct> operationProducts = ppDao.getFinalOperationProductByProcessPlan(
processPlan.getId(), wrCreationDate); // this method return 1 record...

final Property outputProperty = workRequirementEntity
final List<Object> outputs = (List<Object>) event
if (operationProducts != null) {
for (OperationProduct op : operationProducts) {
final GSCWorkOptputProduct outputProduct = OBProvider.getInstance().get(
// outputProduct.setNewOBObject(true);
// outputProduct.setActive(true);
// outputProduct.setCreatedBy(workRequirement.getCreatedBy());
// outputProduct.setCreationDate(workRequirement.getCreationDate());
// outputProduct.setUpdated(workRequirement.getUpdated());
// outputProduct.setUpdatedBy(workRequirement.getUpdatedBy());
// outputProduct.setClient(workRequirement.getClient());
// outputProduct.setOrganization(workRequirement.getOrganization());



System.err.println("WorkRequirement " + ((WorkRequirement) event.getTargetInstance()).getId()
+ " is being created");

Can someone help me?


Giovanni Garofalo

Silambarasan Sekar

Posts: 4

Joined: Fri Sep 03, 2010 11:26 am

Location: Chennai , India

Post Sat May 19, 2012 4:54 am

Re: Event Handler

From my understanding, i think you are not saving the object to the database .Please try the following code inside the for loop at the end of the statement.

OBDal.getInstance().save("Your Object");
Thanks & Regards,

Silambarasan Sekar,

Return to Openbravo Exchange Help

Who is online

Users browsing this forum: No registered users and 1 guest

Website Terms

Designed by ST Software for PTF.