We can run them on the server side in order to make our methods work efficiently according to their needs.
First, remote service description needs to be done. The steps to be taken for this are;
1 -
- Under the Definitions folder, the RemoteServices.lsrv file is selected.
- The Customization Remote Service Definitions Screen opens
- Mouse sağ klik>add tıklanarak Remote Service tanımlama ekranı açılır.
2 - We make the necessary definitions from the Remote Service Definition screen that opens;
Service Name: Service Name
Service Class Name: The class name in which we have methods to work on the server side (an existing class can be selected)
Description: Explanation
3 - In the class that we want to work on the server side, make a sample by recording a student of the student project.
- Our method has to be public because we want to access the method through the client
- There is no client context here because the server side will work. For this reason, the first parameter to the method should be the IServerContext. We determine the remaining parameters as required. In the example method we return a boolean value to the client side.
public boolean transferStudentOnSS(IServerContext context,
Stringname, String surname, GregorianCalendar birthday)
{
boolean ok = true;
IObjectFactory objectFactory = context.getServerObjectFactory();
CustomBusinessObject student = ProjectUtil.createNewCBO("CBOStudent");
ProjectUtil.setMemberValue(student, "StudentName", name);
ProjectUtil.setMemberValue(student, "SurName", surname);
ProjectUtil.setMemberValue(student, "Birthday", birthday);
ProjectUtil.setMemberValue(student,"Identitynr","123456323789");
FactoryParams params = new FactoryParams();
params.setCustomization(ProjectGlobals.getM_ProjectGUID());
try
{
ok = objectFactory.insert(student , params);
}
catch (Exception e)
{
e.printStackTrace();
ok = false;
}
return ok;
}
4 - In order to run this method via ClientSide, first we define a custom form called TRANSFER and drag one button to the form from the designer environment.
- We define the button name as "transfer Student SS".
- From the button events, the method named transferStudentOnSS is defined in the onClick event (triggered when the button is pressed).
- After the definition process, the transferStudentOnSS method is created in the event handler class of the form.
5 - We create a structure in the method that sends parameters to the serverside and defines the result of the operation.
We send the name that we gave when we defined "CSRV" remote Service defined in CallRemoteMetodu, the method name we defined in "TransferStudentOnSS" Server Side, and finally, we send an Object array to send our parameters.If the result.Result and server-side method do not freeze us, we get its result.
(In our example, the server-side method returns a boolean field.) Based on the returned result, we receive a message that says "successful or unsuccessful" in our customization form.
public void transferStudentOnSS(JLbsXUIControlEvent event)
{
try {
RemoteMethodResponse result = clientContext.callRemoteMethod("CSRV", "transferStudentOnSS",
new Object [] {null,"Adı","Soyadı",new GregorianCalendar(1979, 3, 16)});
if ((Boolean) result.Result)
{
ProjectUtil.warn(event, "Başarılı");
}else
ProjectUtil.warn(event, "Başarısız..");
}
catch (Exception e) {
// TODO Auto-generatedcatch block
e.printStackTrace();
}
}