Smart CODE
Your on-line guide to the generated code

NAME
ServerCallbackProc - Thin-client callback, written in the server

INTRODUCTION
A thin-client application is a client-server application where the interface code resides in the client, and the application code (and never any interface code) sits in the server. It may be that for performance reasons some application processing is best done in the client, but the remote server never accesses the interface, only the data that is sent to it.

A single server program will work with X-Designer generated thin clients in Motif, MFC or Java. It also has the potential to work with Web-browser form and applet interfaces, and non-graphical clients.

If you have already developed using Get/Set Smart Code callouts then your code will already be independent of any assumptions about the toolkit. With minimal modification it should be possible to move the processing out of the application and into a callback in the server.

The client side of a X-Designer Internet Thin-client application does not require any coding by the user. If you do need to fine-tune the client side, you can use the precondition/postcondition mechanism, or you can override the data transfer to, or from the server.

The ServerCallbackProc is the callback stub generated as part of the server code. It has full access to the server-side group object - containing the characteristic values of all the members in the group. While it is a group of user-interface controls on the client side, on the server it is a group of data elements.

Each data element corresponds to the setting or value of the controls on the client side. You will be able to check the state of a toggle, the value of a textfield, etc. You will not (directly) be able to control or examine the state of any part of the client interface. If you need further fine tuning, you can add extra elements to the group to handle the features you need to use.

If there is not a one-to-one correspondance between the data structure that is appropriate to the server, and the set of user interface controls, controls can be made private and their data can be processed through extra data elements in the group. These allow the user full control of the data sent down to the server, and how the data returned is reapplied to the interface.

Once you have built and installed the server side application code, you can further develop the client side within X-Designer, using the GoLive! feature, where the interface you are developing in X-Designer is a fully functional thin-client without the need for a compile-cycle.

SYNOPSIS

C

typedef int (*ServerCallbackProc)( sc_data_t *)
	sc_data_t * data;

/* example */ int CALLBACKNAME ( data) sc_data_t * data; { GROUPNAME_t * g = (GROUPNAME_t*)data->group; return 1; }

C++

class METHODNAME_c: public sc_data_c
{
	public:
		int doit();
		static METHODNAME_c * new_METHODNAME_c();

		GROUPNAME_c * getGroup();
};
Java

not available in this release

Inputs

Returns
Non-zero if the data is to be resent to the client after processing.
Other Notes
GROUPNAME, CALLBACKNAME and METHODNAME will be replaced in the generated code by the name you have given to your group, callback or method.

DESCRIPTION

USAGE

EXAMPLES
Simple Server-side callback example
LanguageUsage
C

int
doit_callback  ( sc_data_t * data)
{
	group0_t * g = (group0_t*)data->group;

	if (SC_GET(g->toggle1))
		SC_SET(g->text1, "Hallo World");
	else
		SC_SET(g->text1, "Farewell Cruel World");

	return 1;
}
C++

class doit_method_c: public sc_data_c
{
	int doit()
	{
		group0_t * g = getGroup();

		if (g->toggle1->get())
			g->text1->set("Hallo World");
		else
			g->text1->set("Farewell Cruel World");

		return 1;
	}
};
Java

not available in this release
     

Callback that requests further polling from the client
LanguageUsage
C

#include <time.h>

int
doit_callback  ( sc_data_t * data)
{
	group0_t * g = (group0_t*)data->group;
	time_t t;

	time( &t);

	SC_SET(g->text1,ctime(&t));

	data->poll = 10; /* retry every ten seconds */

	return 1;
}
C++

#include <time.h>

class doit_method_c: public sc_data_c
{
	int doit()
	{
		group0_t * g = getGroup();
		time_t t;

		time( &t);

		g->text1->set(ctime(&t));

		setPoll(10); /* retry every ten seconds */

	return 1;
};
Java

not available in this release
     

SEE ALSO