File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Can I get code for 'CTRL F' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can I get code for Watch "Can I get code for New topic
Author

Can I get code for 'CTRL F'

natam holla
Greenhorn

Joined: Nov 09, 2009
Posts: 9
I am developing a Java web application.
In all its view page it should have a search button to search the specific object in that particular page only.
It should something work like Ctrl F .
Can any body help me out with the code.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42915
    
  68
Welcome to JavaRanch.

What effect would that search functionality have? How would it be different from using the browser's search function?
natam holla
Greenhorn

Joined: Nov 09, 2009
Posts: 9
Take for an example....
It will have a web page containing 1000 country names.
In the top right side of the page, it should have a text box with a search button.
It should be validated such that, before entering any letter or word in the Search text box, the search button should be blur.
But once you type a single word in the Search text box, it should be activated.Ex:Type 'Tokyo' , in text box.
If its present, it should be highlighted with some color(where all present.)..if not message ' no such string/letter present'...should arrive.


Can you help me out....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42915
    
  68
Isn't that pretty much what the browser's search function does? I don't understand the point about "validation", though.
natam holla
Greenhorn

Joined: Nov 09, 2009
Posts: 9
Yes, its the same.....
You help me out with that code only...
You don't worry about validation.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42915
    
  68
If it is the same as what the browser does, then why is it even needed?
natam holla
Greenhorn

Joined: Nov 09, 2009
Posts: 9
In my web application. I am not supposed to use browser functionality.
So i need code for this....
Please help me out...

Thanks in advance....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42915
    
  68
In my web application. I am not supposed to use browser functionality.

You're not - the user is using the browser like it was intended to. If there's no further reasoning than this behind this requirement, then I'd advise to question it.
natam holla
Greenhorn

Joined: Nov 09, 2009
Posts: 9
In all the view pages there should be a search button to search the specific object........This is the requirement.
Did you get my point....
Will you help me out.
Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

If you have to do it... maybe source code of a browser helps.
But I agree with Ulf on the design.

Anrd
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

you can also integrate google search in your website.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

natam holla wrote:In all the view pages there should be a search button to search the specific object........This is the requirement.
Did you get my point....
Will you help me out.


Seems like a lot of work to replicate functionality that is already there. I'm with Ulf, I'd ask why this were needed first. Writing something that searches the current DOM in JavaScript is easy enough, but that would be seperate of the browsers own search capabilities.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
natam holla
Greenhorn

Joined: Nov 09, 2009
Posts: 9

I need the code.....please
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Calling browser specific functionality from a web page is pretty much a non-starter - I can't think of any way to call the functionality of the Edit>Find menu without using something like ActiveX in IE for example. Repeating this functionality in JavaScript is easy enough to do. Google for JavaScript search in page and you will get a whole bunch of examples.
natam holla
Greenhorn

Joined: Nov 09, 2009
Posts: 9
Thanks a lot Paul!!!
suchit pandya
Ranch Hand

Joined: Oct 27, 2009
Posts: 43
If you want to impliment anythin on search then you will not have to do much work in database query.

In java code following things you need to do.

1) put a button or image of searching and call a javascript function on click on that.
2) Write a function in java script, Do all validations in it, after validation pass value of search txt box to java code.
3) append search criteria in where clause of your select query (a query which gives you results at first time when you open the page) and return all selected records to JSP page.

if you want code then you have to give more detail like which architecture you are folloing, then which type of search you want.

Like you want to give searching on perticular field in jsp
E.G say JSP displays detail of person then search name field, or search in surname field etc.

I had already developed such functionality in MVC structure.

Hope this will help you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can I get code for 'CTRL F'