• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

search-- action Performed:

 
Mary John
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,


Can some of you comment on my actionPerformed method for the SearchButton's actionListener.

What you think of the way I create the criteria string?
My business layer is on server side and it will return an ArrayList to
client and then a TableModel is populated and JTable is set. ? How about that?
This actionPerformed method can handle cases where
1. user search by name only
2. user search by location only
3. user search by name and location

I do not allow search of name Logical OR location, as it doesnt make much
sense to me.? what you think?

Thanks

Thanks

 
rinke hoekstra
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mary John,

Originally posted by Mary John:

What you think of the way I create the criteria string?


Seems OK to me. I only have a 2 element array; any missing elements are
interpreted as null.




My business layer is on server side and it will return an ArrayList to
client and then a TableModel is populated and JTable is set. ? How about that?

I did the same.


This actionPerformed method can handle cases where
1. user search by name only
2. user search by location only
3. user search by name and location

I do not allow search of name Logical OR location, as it doesnt make much
sense to me.? what you think?

Again, I did exactly the same.

Rinke
 
rinke hoekstra
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some extra remarks:

Though no long waiting times are to be expected, when working with networks, you could always get lousy connections. Displaying a waiting dialog ("please wait, busy...") is most probably overdoing it because creating the dialog would take more time than the actual search action itself, the least thing you could do is change the mouse cursors.

At the start of any book or search method, set the cursor to Cursor.WAIT_CURSOR; at the end of the actionPerformed, set it back to default (preferably in a try/finally block).

Not much effort, but informative for the user if for some reason the search takes a bit longer.

though, of course, this is more appropriate for the book method than for the search method.


Another point: have you considered creating a Value Object? Personally, I find the ArrayList<String[]> very ugly. Though this is maybe not enough reasons for going in the effort of creating a value object class.
 
Mary John
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rinke

I havent yet considered using a value object but recetnly I have been thinking about it as I needed to have a record number in addition to String[] record data, ofcourse we can have in String[] but doesnt sound good to me.

Did your value object just wrap the String[] or did you have individual fields for each column of the table.
eg
class ContractorRecord{
long recno;
string name;
string location;
....
getters.....
setters.....
}

or class ContractorRecord
{
long recno;
string[] record;

getters....
setters...
}

Thanks about the information of using a cusor waiting mode. that was useful, and also easy after you mentioned it...:-)
 
Mary John
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
again I noted another point in your reply about the way I formatted my criteria array. Thaks for pointing that out too.


I totally ignored that the findByCriteria would have to accept nulls in criteria array to return all records. However I was surprised that even though my criteria array was all "" empty strings, it still returned all records because all fields matched "" in the startsWith checking
 
rinke hoekstra
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mary John:

Did your value object just wrap the String[] or did you have individual fields for each column of the table.


In fact, I haven't decided yet. Most fields are just not needed, so it seems a bit like doing work for nothing when putting these in a field.

Rinke
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic