Implementing ‘Got_focus’ Event in Smart Client
Q: Clear Basic provide ‘got_focus’ event for controls but I can’t find the same event in smart client.
Is there any way to implement this feature in smart client?
A: You can add your native contol focus event listeners (lost/gained) as follows:
(assuming your control is a textBox named ‘txtCustomerName’)
// Add the following in the form_Load() event handler: // define focus event listeners (lost/gained) ( (javax.swing.JComponent)this.txtCustomerName.getNativeControl()) .addFocusListener(new FocusListener()
{
// this is the equivalent to Clear Basic Lost_Focus()
public void focusLost(FocusEvent focusEvent)
{
// your logic here...
System.out.println("focus lost");
}
// this is the equivalent to Clear Basic Got_Focus()
public void focusGained(FocusEvent focusEvent)
{
// your logic here...
System.out.println("got focus");
}
}
);
Using Contained Core Business Objects
Q. When working with establish relation, I had a problem with a Bo having many parent, like:
1. We have an exist CaseBo object: caseBo
2. By using XVO, we create 2 new row to insert: emailLogBo and actEntryBo
3. In which: actEntryBo is child of both caseBo and emailLogBo, emailLogBo also is child of caseBo.
=> how can I insert emailLogBo and actEntryBo to database ?
Note that: Both emailLogBo and caseBo are parent of actEntryBo, so we can’t use actEntryBo.setParentBo(..) to set up relation. So, please suggest how to solve this problem.
A. Note that CaseBo object contains all the logic to do it automatically for you.
All you need to do is to add your new emailLog record to the CONTAINED emailLogBo.
When doing so, an actEntry will automatically be added and related with all relevant BO parties (CaseBo, UserBo, EmailLogBo).
About Contained Business Objects
Many BOs Contain other Business Objects. These contained CBOs are exposed as properties of the containing BO. For example, when a Case BO is created, contained BOs are automatically created for the logs related to the cases, the site and contact that reported the cases, and the installed part identified in the case
These contained CBOs are automatically related to the Case BO, usually as child BOs of the parent BO. They are accessed through CaseBO properties.
Field values for contained CBOs are accessed through properties of the containing BO
The following code shows how to get the first name of the contact who logged a case: String firstName=boCase.getContact().toString(“first_name”);
Note:
- Most contained CBOs are Generic BOs.
- To reduce network traffic and improve response times, many contained BOs set bo.DataFields and bo.QueryMode to minimize the amount of data retrieved. Make sure to modify the DataFields property of the contained Bo to include necessary fields before performing the query.
Example:
String fields= boCase.getContact().getDataFields() + ",e_mail"; boCase.getContact().setDataFields( fields ); boCase.query();
Example of adding email log to a CaseBo:
// Add a new row to the contained EmailLog BO. boCase.getEmailLog().addNew(); // Set the note description for the new row. boCase.getEmailLog().setValue("description", "Customer mailed again to ask about the case status"); // Commit changes to the database. boCase.update();