NextGen Consulting

IT Consulting CRM BSS OSS

Implementing Form to Form Messaging

Smart Client Messaging

Smart Client messaging is far more flexible than its Classic predecessor. Smart Client forms can communicate with other forms by messaging. The UifForm class provides two APIs to support messages:

1.     Send a message to a specific form:

this.sendMessage (UifForm, String, Object)

2.    Send a message to a group of forms:

this.sendMessage (UifFormTarget, String, Object)

UifFormTarget is an Enum that identifies the predefined group of forms,

e.g., OPENERS, DESCENDANTS

The forms that are interested in receiving messages should provide a callback method. The callback should accept UifMessageEvent as the argument.

For example:

public void message_CustomerCreated(UifMessageEvent event)
{
}

The UifMessageEvent contains information sent by the sender.

When sending message to multiple forms, the message is sent to forms sequentially.

 

About sendMessage parameters:

UifForm is a reference to the target form. Any form can be referenced using API’s such as:

<form class> targetForm = <form class>getWorkspace().findForms(null, null,<form class>.class.getName(), null)[0];
<form class> targetForm = <form class> this.getWorkspace().getActivatedForm();
<form class> targetForm = <form class>this.getWorkspace().getFormByName (keyString);
<form class> targetForm = <form class>this.getParentForm();

 

or directly related form:

<form class> targetForm = <form class> getParentForm();
<form class> targetForm = <form class> getChildForms();

The String parameter is any message identifier (i.e: “UPDATE”) which will be used to identify the callback method in the receiving form:

public void message_UPDATE(UifMessageEvent event)
{
}

    

The Object parameter is the data passed in the message. It can be a single string, string array, or any complex datathat needs to be passed.

To use the passed data, you need to extract it from the UifMessageEvent event.

Example:

public void message_UpdateReasonCodes(UifMessageEvent event)
{
if(event != null)
{
String[] info = (String[])event.getData();
if(info!= null && info.length > 0)
      this.topicDM.setStringValue("reason_1", info[0]);
if(info!= null && info.length > 1)
      this.topicDM.setStringValue("reason_2", info[1]);
} // event
else
{
     System.out.print("Null event, could not update reason codes.");
}
} // message_UpdateReasonCodes

No comments yet.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.