Pratibha Gayake

Greenhorn
+ Follow
since May 08, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Pratibha Gayake

I am not able to pass String criteria to criteriaFind method.
I construct this criteria string in Search class as per follwoing.
/* following is a Search class to populate the values from Database and construct the String criteria
public class Search extends JFrame implements ActionListener{
....
...
...
jlb1 = new JLabel("Origin airport");
jlb2 = new JLabel("Destination airport");
jcb1 = new JComboBox(fbn.getFlight());
jcb2 = new JComboBox(fbn.getFlight());
jb1 = new JButton("Search");
jb2 = new JButton("Clear");
/* all these components are added in a Panel using GridBgaLayout and added actionListener to "search" and "Clear" Buttons*/
public void actionPerformed(ActionEvent event){
Object source = event.getSource();
if(source == jb1){
sb = (jlb1.getText()+"='"+jcb1.getSelectedItem()+"',"+jlb2.getText()+"='" +jcb2.getSelectedItem()+"'");...................Line B
/* String sb is then passed to criteriaFind() method in FbnTableController class.
}
//FbnTableController class is as per following
public class FbnTableController{
private String[] names;
private DataInfo[] dInfo;
private FieldInfo[] field;
MainTableModel mainModel = new MainTableModel();
//This class only holds Data from database, and has getter and setter method.
public FbnTableController(){
try{
dt= new Data("db.db");
dInfo = dt.criteriaFind(String sb);
//here I want to pass the String sb constructed in Search class. I am not bale to figure out how to pass String sb, which is constructed when "Search" button is pressed

field = dt.getFieldInfo();
names = new String[field.length];
for(int i=0;i<field.length;i++){>
System.out.println("field Name" +field[i].getName));
names[i] = field[i].getName();
}
}
catch(Exception e){}
}
public MainTableModel setDetails(){
mainModel.setColumnNames(names);
mainModel.setTableRows(dInfo);
return (mainModel);
}
}
Pratibha
You must be filling your JComboBox from Database using Vector or Array. Then first add "ANY" to the Vector and fill the remaining from db.db. So in GUI you will display first "ANY" then reamining "ABQ" ,"ATL" and .....stuff.
Is it clear.
Pratibha
Thanks Marks for your earlier reply.
Hello Raju,
I am approaching my GUI as per following,
Part 1:
1.I designed one single Panel with gridbaglayout, components like JComboBoxes, JLables and Buttons for "Search" and "Clear" are added.
2. Method getFlight() fills the Origin and Destination JComboBoxes from Database.
3. I first tried to display all above stuff. I still have not handled event handling upto this point.

Part 2:
I created a JTable by using MVC pattern.
Model - MainTable , which holds data of Databse and has getter and setter methods for columnNames and rows(rows of DataInfo)
Controller - Uses Setter method of mainTable. This class has criteriaFind("Origin airport='SFO'") method.(This criteria is not from JCoboBoxes, it is a fake criteria , just to test whether my JTable is created with this criteria.) The result of criteriaFind is used to set the values in MainTable.
FbnTableModel- This class extends AbstractTableModel and implements getRowCount(), getColumnCount,getValueAT() method. These methods basically use getter methods from MainTable.
Finally View - extends JTable and dispalys the Jtable.
My Part 1 and Part2 are not still linked. Means whatever criteria I selected in part 1 is not passed to Part 2 to display JTable. I just divided GUI in two parts so that I can write, test the code separately. Now I am sure for functinality of both.
Now I am going to combine the two parts. I have formed the String criteria from Comboboxes. And I am working to pass this String criteria, from part 1 to Part 2, to dispaly the JTable.
Hope it helps
Pratibha
I am still looking for answer for Question 2,
Question 2: I am constructing String critaria as "Origin airport='SFO', Destination airport='Bom'" and not as
[b]"Origin='SFO', Destination='Bom'"[b] given as per SUN requirements. Because my criteriaFind() methos needs complete name of fields to passed. So that it compares with database fieldnames. I will document in my Design documnet all this stuff.
Is this O.K.? Or the marks will be reduced.
On the other hand, perhaps I dont need to store this information at all and I just need a seat count. I sent a note to Sun about this, but have not heard back from them.
Yes, there is no need to store the information of customer. Just decrease the number of availabe seats in db.db.
Pratibha
Hello everybody,
Following are the lines from requirements
/* Start here*/
public DataInfo[] criteriaFind(String criteria)
This method searches the database for entries matching the criteria supplied. Criteria take the form of a comma separated list of <field name>=<value to match> specifications. For example, the following argument string would select all records describing flights by the SpeedyAir carrier that originate in San Francisco. "Carrier='SpeedyAir',Origin='SFO'" /*Line A*/
/*ends here*/
I got stuck with construction of String criteria. As per my understanding, once I get values of Origin and destination airports from JComboBoxes, then I have to convert that values into String criteria = "Origin airport='SFO',Destination airport='Bom' ". And pass this String to public DataInfo[] criteriaFind(Strring criteria).
For costructing this String criteria in the format given by line A, I have used follwoing method
/* following is a Search class to populate the values from Database and construct the String criteria
public class Search extends JFrame implements ActionListener{
....
...
...
jlb1 = new JLabel("Origin airport");
jlb2 = new JLabel("Destination airport");
jcb1 = new JComboBox(fbn.getFlight());
jcb2 = new JComboBox(fbn.getFlight());
jb1 = new JButton("Search");
jb2 = new JButton("Clear");
/* all these components are added in a Panel using GridBgaLayout and added actionListener to "search" and "Clear" Buttons*/
public void actionPerformed(ActionEvent event){
Object source = event.getSource();
if(source == jb1){
sb = (jlb1.getText()+"='"+jcb1.getSelectedItem() +"',"+jlb2.getText()+"='" +jcb2.getSelectedItem()+"'");...................Line B
/* String sb is then passed to criteriaFind() method.
}
Question 1: So my Line B constructs String into form "Origin airport='SFO', Destination airport='Bom'" . Is this a correct way of doing it? Or I am going in wrong direction? Any hint to construct the String is appreciated.
Question 2: I am constructing String critaria as "Origin airport='SFO', Destination airport='Bom'" and not as
[b]"Origin='SFO', Destination='Bom'"[b] given as per SUN requirements. Because my criteriaFind() methos needs complete name of fields to passed. So that it compares with database fieldnames. I will document in my Design documnet all this stuff.
Is this O.K.? Or the marks will be reduced.
Thanks
Pratibha

OK, I got the answer.
Thanks
Pratibha
I am sorry, the original code is as per following: (It was my typing mistake)
public FbnTable(MainModel model){
columnNames = mainModel.getColumnNames();
//Problem is here: Here it gives NullpointerException, colNames gets null value even after setting the values in MainModel by FbnTableController
rows = mainModel.getTableRows();
}
I am really sorry for this.
Pratibha
Hello Dave,
I am facing following problem while using MVC pattern for constructing JTable (This is in line with your earlier post for MVC pattern);
/* follwoing is MainModel class
public class MainModel{
private String[] columnNames;
private DataInfo[] rows;
//getter and setter methods for columnNames and rows
}
/*following in FbnTableController class which uses setter method of MainModel*/
public class FbnTableController{
private String[] names;
private DataInfo[] dInfo;
private Data dt;
private FieldInfo[] field;
//this constructor sets the values of coulmnNames and rows in
//MainModel
public FbnTableController(){
try{
dt = new Data("db/db");
dInfo = dt.criteriaFind("Origin airport='SFO'");
field = dt.getFieldInfo();
for(int i=0;i<field.length;i++){>
//in following loop,name[] fills with field name
names[i] = field[i].getName();
}
mainModel.setColumnNames(names);
mainModel.setTableRows(dInfo);
}
catch(Exception e){}
}
}
/*Following is FbnTable which extends AbstarctTableModel*/
public class FbnTable extends AbstractTableModel{
private String columnNames;
private DataInfo[] rows;
//Follwoing instance of FbnTableController now set
// the columnNames and rows in MainModel
private FbnTableController cont = new FbnTableController();
public FbnTable(MainModel model){
colNames = mainModel.getColumnNames();
//Problem is here: Here it gives NullpointerException, colNames gets null value even after setting the values in MainModel by FbnTableController
tableRows = mainModel.getTableRows();
}
//following mathods are implemented
public int getRowCount(){}
public int getColumnCount(){}
public int getValueAt(){}
}
/* FbnClient class is also there, which creates instance of FbnTableModel, and passed to constructor of JTable, which then passed to JScrollPane*/
Any help is welcome. I have tried to implement MVC pattern by using two classes, but I was not able to differentiate the functinality of Model and view and controller in two classes.
Pratibha
It is the person who started the topic who has deleted it.
I think only moderators should decide and have authority to delete any particular topic.
What is the idea of giving permission to delete a topic, who started it? (In general I am asking, not particular about this case.)
Thanks for help.
Pratibha
No, I have not posted that topic. But I replied that .
Now I want to see it for my reference, I am not able to see it.
Yes, it was availabe for 2-3 days. Since yesterday night I am not able to see it.
If you "search " for that topic Method of AbstractTableMethod Class "public Object getValueAt(int r, int c){....} then you can see the above in the list of search result.
If you click on that then "The page can not be found" error comes.
I appreciate any help regarding this.
Pratibha
I am not able to view following topic, which was posted on 09/28/2001:
Method of AbstractTableMethod Class "public Object getValueAt(int r, int c){....}
Pratibha.
As per the requirement, for basic search in GUI, you should give only two option "Origin airport" and "Destination airport".
If you have time, then in advansed search you can put other fields such as "Price", "Carrier", "Day".(As per requirement this is not required). If you are providing all these options, then it should be "Day" field not the "Date".
I have designed my GUI as per above. I am still working on GUI.
Pratibha
I think, you have to register again with different name. You can not modify the same name "nitin_k".
Pratibha