This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes best way to show editable search results in page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "best way to show editable search results in page" Watch "best way to show editable search results in page" New topic
Author

best way to show editable search results in page

ravi v kumar
Ranch Hand

Joined: Dec 14, 2004
Posts: 56
Hi all,

i had a requirement as below

there will be search screen, once the user click search. we have to show the results, these results will have one editable field and i have show this like paging technique. worst case of search results will more that 1 lakh

i tried 2 ways
1. i taken the complete resultset and using javascript and dhtml i wrote the paging technique and after that i used session to store the selected rows.
2. i used rownum to build the paging technique but its very slow because it queries the DB every time once the user clicks next or previous links

both of the ways i am not happy, another alternate which i am thinking is:
shall i take the entire resultset and place it in session object and apply the paging technique to this session object.

can anybody suggest best to do this, thinking in mind that these results are editable.

thanks in advance
ravi
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Retrieving the complete thing is useless, as you need to show just a few on the page. And the fact is the user might not browse all the pages. Hence, no need to query the complete set of records matching search criteria.

Having said that, you should get only the results you are going to show on your first page and query the database every time request come for the next. The detail of HOW-TO is given here.

Now, regarding editable results. Is there any problem in how to implement it?
[ January 03, 2008: Message edited by: Adeel Ansari ]
ravi v kumar
Ranch Hand

Joined: Dec 14, 2004
Posts: 56
hi adeel,

thanks for the post. as you said using pagination, its difficult to hold the user input like we will have check box for every result row and user can select a list of rows and go for submit.
because with pagination, request will go to server every time if next or previous link is clicked.

take for example, user selects 2 rows in first page, and then he click next and then he selects 3 rows and then he clicks submit button.
at this time we will data for only 3 row which was selected my user.
the 2 rows selected my user in page one will be gone out of scope.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
No, no , no. I mean think of this as a shopping cart thingy.

- Selecting records means putting things into the cart
- Moving to the next page means browsing more stuff to choose
- And submit means submitting the cart finally

Are you getting me?
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Your last post got posted thrice. You can delete the extra two by editing your post. You find a checkbox "Delete Post" on your left on the edit page.

Thanks.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
By the way, it doesn't really feel right to me that, the user must check the box to tell that this is the record I have modified. Isn't it like this?

If yes then, its good place to use AJAX. I mean, remove all your checkboxes. And make an AJAX call on onchange event to modify that particular record. There would be a number of advantages as well, like

- This way you don't have to keep track of selected records
- Immediate response to the user
- Clean, orderly and neat solution
ravi v kumar
Ranch Hand

Joined: Dec 14, 2004
Posts: 56
hi adeel,

the requirement is same like you suggested. we will provide check box and we ever user selects some and clicks "ADD TO LIST" button, it will be added to his cart (i mean session variable). he can came again back to search a new result and repeat the above.

i did most of it, but the thing haulting me is query execution every page[pagination]. my search query joins 7 tables. executing this query infact 2 same query once count(*) and actual results for every page taking lot of time.

i am looking for indexing tables, views, tuning. i beleive 25k-50k records is not much data to apply pagination.

suggest me if had any info regarding tuning the query.

thanks again
Ravi
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by ravi v kumar:
i did most of it, but the thing haulting me is query execution every page[pagination]. my search query joins 7 tables. executing this query infact 2 same query once count(*) and actual results for every page taking lot of time.

Regarding pagination/paging.


i am looking for indexing tables, views, tuning. i beleive 25k-50k records is not much data to apply pagination.

suggest me if had any info regarding tuning the query.

Yes, it might be a good idea to join those particular tables to create a view. It would make it easy to query.

Other option is a must. You must introduce indexes on the columns used to make conditions. If already there, you can try to tune the indexes. You can do it by dropping and creating one again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: best way to show editable search results in page