• Post Reply Bookmark Topic Watch Topic
  • New Topic

sending message to client

 
sachin dabhade
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have an application where the client calls a remote method using RMI.
i have a swing interface for client.
on the click event of button,i am calling some method.
the method is executing finely.
what i want to do is send a message back to the client that the execution succedded.
i can write a message on server console using System.out.println("Process successful");
i want the same message to be displayed on client console.
can anybody help me??
thanks in advance.
sachin
 
Hema Menon
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a newbie with RMI, but was wondering, why not return a "successful" message string from the remote method that is being called on the push of the button. The return message can then be displayed on the client window.
Hema
[ June 06, 2002: Message edited by: Menon Hema ]
 
Hema Menon
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I misunderstood your question. Are you looking for callback notification?
 
sachin dabhade
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont want to do that.
i want to call a method on server,if that method is successful only then i want to display message.
how can i fire the message on client side on button event before executing the function.
 
James Cook
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are not going to use callback notification - and I can see why because this will flash up a message at a random interval of time according to when the server has successfully completed your operation, which might not be when you want to display it in the Client, then the way to do it, I think is to have the Server throw an Exception if the operation fails.
then, you wrap the client code (inside the button event handler) in a try block, something like this:-
try
{
call serverMethod();
JOptionPane.showMessageDialog("Operation completed successfully", "", JOptionPane.INFORMATION_MESSAGE); // check the syntax for me!!!
// or you could print to the client's console here instead
}
catch(ServerMethodFailureException a)
{
// display some error either in a JOptionPane, or on the console
}
hope this helps.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!