Originally posted by Sam O'Neill:
For example my model returns DataInfo[] for the data and a Set for the Origins and Destinations.
How did you translate Object to what you wanted in the gui of did you have a Table model etc that accepted an Object argument?![]()
Many, many thanks
Sam
Object[] getFlights()
typically,[as i have done] you will send the column names appended in the first row.
update(int updateType, Object data)
switch updateType:
case SEARCH:
setData(Object[] )data;
Aadhi
Originally posted by Sam O'Neill:
I need my origins and destinations at program startup thats is why they will be either pushed or pulled to the gui.
My real question is how do I convert the Object value received by the gui in the modelChanged() method for a push to a useful data type such as DataInfo[] that I can store in my table model? If I try and cast I get a class cast exception at runtime understandably.
Aadhi
the Model pushes Object[][] (in reality it should a String[] because View doesnt recognise objects like a Flighs object or an employee object, instead it can recognize a String[]
Originally posted by Sam O'Neill:
I'm not sure what you mean Aadhi with the following:
How can an Object[][] be a String[] - one is a two-dimensional array and the other a single.
So you are converting DataInfo[] to String[] or String[][] and then passing that back to the gui?
Aadhi
Originally posted by Eugene Kononov:
Here is what you can do in View:
Eugene.
Aadhi
Originally posted by Eugene Kononov:
public void modelChanged(String notificationType, Object data) {
if (notificationType == NotificationType.ORIGIN_AIRPORTS) {
String[] origins = (String[])data;
for (int i = 0; i < origins.length; i++)
originAirportCombo.addItem(origins[i]);
}
}
[/CODE]
Eugene.
Aadhi
Originally posted by aadhi agathi:
the outer view will pull the values which "wont change after startup" like the destination airport, origin , carrier etc and the push approach for more generic /reusbale events like search and book.
SCJP, SCJD, SCEA 5
Voted JavaOne Rock Star in 2010 and recognized as a Java Champion in 2020.
"Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Originally posted by Burk Hufnagel:
What makes you think they won't change? Just because the client you are writing doesn't modify anything but the number of available seats in a record doesn't mean that some other client won't.
Aadhi
Originally posted by Sam O'Neill:
Thanks everyone.
Burk I am initialising the origins and destination at startup but that's it. I agree that another application could be modifying the database such that an item in the list is no longer available after startup but all that means is that the user will get a message such as
"Sorry no flights available for the chosen criteria at this time"
Aadhi
Originally posted by Sam O'Neill:
Thanks everyone.
Burk I am initialising the origins and destination at startup but that's it. I agree that another application could be modifying the database such that an item in the list is no longer available after startup but all that means is that the user will get a message such as
"Sorry no flights available for the chosen criteria at this time"
Aadhi
Aadhi
Eugene , i have got a query. does the NotificationType equivalent to the notification contract between the View and the Model or is it altogether a separate class.