Hi guys.
I have an observer/observable structure set up in my code that changes a bunch of TextField values with updated data, no big problem here. However, in my update(Observable obs, Object arg) method, I am trying to call another method to insert the new values into my database.
I have tried the method calling code elsewhere and it writes to the database fine, so I'm wondering if there is some kind of restriction on calling other methods in the "update" method because it is a special observer/observable method?
Here is what I mean:
public void update(Observable obs, Object args){
Location loc = (Location)obs;
weatherOverview.setText(loc.getWeatherOverview());
String temp = Double.toString(loc.getTemp());
temperatureField.setText(temp);
windDirection.setText(loc.getWindDirection());
String spd = Double.toString(loc.getWindSpeed());
windspeedField.setText(spd);
pressureField.setText(loc.getPressure());
String date = getDateAndTime();
String location = loc.toString();
locateServer();
try{server.writeWeatherHistory("a", "b", "c", "d", "e", "f", "g");}
catch(Exception e){}
}
The red lines are the section that isn't working. the locateServer() method is necessary for calling the "writeWeatherHistory" method via RMI. This code works when it is outside of the update method but it would be very good if it would work whenever update is called, so that the new data can be inserted at the right time.
The string variables in the writeWeatherHistory method are for test purposes only, in reality I would put in all the String values assigned to the above text fields.
But yes, any replies greatly appreciated