This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Event Handlers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Event Handlers" Watch "Event Handlers" New topic
Author

Event Handlers

Prakash Nathan
Greenhorn

Joined: Sep 11, 2005
Posts: 6
Hi,

Could you please suggest a way to implement the following requirement in JSP?
Consider the following text is present in a JSP Page.

"This is a sample text"

When the user do a "double click" on any of the above words, i need to invoke a servlet. Is there any way to capture the 'double click' event.

Thanks!
Prakash A
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Yes, as with everything else on an HTML page, with Javascript.

Moved to the HTML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
wrap it in a span tag and add ondblclick and call a function that posts back the page.

Eric
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 815
Eric,
Do you have a listing of browsers that support the span tag? Thanks.

Rob
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
ALL current day browsers....It is an HTML element just like the div and table elements
Prakash Nathan
Greenhorn

Joined: Sep 11, 2005
Posts: 6
Thanks for your replies.

Let me explain wat exactly my requirement is.

JSP file has the following senetence.
"parameter1 parameter2 parameter3"

If the user, double clicks on any of the parameter i need to invoke a servlet and pass that particular parameter to the servlet.

How to accomplish it?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Surround them with spans as I suggested

<span ondblclick="alert("bar");">foo</span>

Eric
Prakash Nathan
Greenhorn

Joined: Sep 11, 2005
Posts: 6
Hi Eric,

Wrapping the text with SPAN tag is fine.
But, i really have a lots of information to be displayed in the page.
Example, 5-6 paragraphs.

In this case, it would not be fair to wrap each & every word in the paragraph. Is there any global way to accomplish this?

Prakash A
 
wood burning stoves
 
subject: Event Handlers
 
Similar Threads
Firing events from an applet
Urgent: pls help: Getting error when trying to open a jsp or html file in WSAD
Check to see if a button is clicked once or twice
Login into JSP through JAVA
double click for a href