Programming Extension Requests
As a developer of JMap Pro extensions, you will probably be developing applications that need to communicate between the client side and JMap Server. Whether you need to communicate with your own extension on the server side or to make general requests to JMap Server, the programming principle is the same.
For more information on client-server communication in JMap, refer to the Client-Server Communication section.
Programming the request
To create your request class, you must observe the two following rules:
| • | The class should be derived from the JMapExtensionRequest class; |
| • | All of the class's properties must be serializable. |
You are free to add all the properties and methods that are useful to executing your request. These properties and methods can be used by your extension on the server side.
The following source code example demonstrates how to program a simple request.
// This request is used to save a new citizen complaint |
Programming the response
To create your response class, you must observe the two following rules:
| • | The class should be derived from the JMapExtensionResponse class; |
| • | All of the class' properties should be serializable. |
You are free to add all properties and methods that are useful to returning the information regarding the request's execution to the client. These properties and methods can operate from the client side by your extension after the request is executed on the server.
The following source code example demonstrates how to program a simple response.
|
Being derived from the JMapExtensionResponse class, your response class will inherit some useful properties, including the response status and an explanatory message in case of a problem.
Response status
Each response has a status that indicates if the request was executed successfully or if a problem occurred. The getStatus() method of the JMapExtensionResponse class allows you to get the status of the response. For the list of possible statuses and their description, refer to the documentation of the JMapExtensionResponse class.
Your extension should always check the status of a response before using it. If the status is not equal to JMapSRV_STS_SUCCESS, a special process must occur in order to manage the error. In this case, the getMessage() method allows you to generate a message explaining the cause of the error.