}
public void actionPerformed(ActionEvent e) {
String command=e.getActionCommand();
RspList rsp_list;
try {
if(command.equals("Get")) {
String stock_name=stock_field.getText();
if(stock_name == null || stock_name.length() == 0) {
showMsg("Stock name is empty !");
return;
}
showMsg("Looking up value for " + stock_name + ':');
rsp_list=disp.callRemoteMethods(null, "getQuote", new Object[]{stock_name},
new Class[]{String.class},
GroupRequest.GET_ALL, 10000);
Float val=null;
for(int i=0; i < rsp_list.size(); i++) {
Rsp rsp=(Rsp)rsp_list.elementAt(i);
Object obj=rsp.getValue();
if(obj == null || obj instanceof Throwable)
continue;
val=(Float)obj;
break;
}
if(val != null) {
value_field.setText(val.toString());
clearMsg();
}
else {
value_field.setText("");
showMsg("Value for " + stock_name + " not found");
}
}
else
if(command.equals("Set")) {
String stock_name=stock_field.getText();
String stock_val=value_field.getText();
if(stock_name == null || stock_val == null || stock_name.length() == 0 ||
stock_val.length() == 0) {
showMsg("Stock name and value have to be present to enter a new value");
return;
}
Float val=new Float(stock_val);
disp.callRemoteMethods(null, "setQuote", new Object[]{stock_name, val},
new Class[]{String.class, Float.class},
GroupRequest.GET_FIRST, 0);
showMsg("Stock " + stock_name + " set to " + val);
}
else
if(command.equals("All")) {
listbox.removeAll();
showMsg("Getting all stocks:");
rsp_list=disp.callRemoteMethods(null, "getAllStocks",
null, (Class[])null,
GroupRequest.GET_ALL, 5000);
System.out.println("rsp_list is " + rsp_list);
Hashtable all_stocks=null;
for(int i=0; i < rsp_list.size(); i++) {
Rsp rsp=(Rsp)rsp_list.elementAt(i);
Object obj=rsp.getValue();
if(obj == null || obj instanceof Throwable)
continue;
all_stocks=(Hashtable)obj;
break;