Handling mouse events in JSP

Hi ,
I have to handle mouse events in JSP,means i have to handle the event
of the user i.e, if he press the lest click we have to handle that
event where he pressed it with JSP. Iam finding examples in Applets ,
nut i have to do it in JSP.Can any body help me please? it's very
urgent.
Thanks in advance
BhargavKumar.B

JSP cannot catch mouse events. You need a clientside language for that, such as Javascript. So catch the mouse click event in Javascript, get the desired information from it and send it as request parameters to the server, so that the serverside logic can intercept on it. You can use AJAX for that, if you want to do it asynchronously.

Similar Messages

  • Handling mouse events anywhere

    Hi,
    We have built an application with a Swing GUI and for automation and testing we would like to record all keyboard and mouse events to be able to play them afterwards.
    The keyboard events can be recorded easily with a KeyboardFocusManager but for the mouse events I still need a solution.
    The GUI consists of a JFrame containing several JPanels. When I add a MouseListener on the JFrame, its mousePressed and mouseReleased events are not called everytime I click somewhere on the frame. For example, when I click on a button inside one of the JPanels, the mouse event methods of the frame are not executed.
    Can somebody tell me how I can easily capture all mouse events in the GUI without adding MouseListeners in every JPanel??
    Thanks in advance...

    I know how to use the Robot class, that's not really the issue.
    What we are doing actually is writing keyboard and mouse events into a file.
    Afterwards we use the Robot class to playback the events in the file. This is no problem, I just don't know how I can easily intercept ALL mouse events in the GUI without adding mouseListeners in each component in the GUI.

  • RichEditableText with embedded images does not handle mouse events reliably

    I'm using Flash Builder "Burrito".  downloaded a couple of weeks ago.  Flash Player 10.1.85.3 debug version.
    I have the following MXML object:
    <s:Scroller
    width="100%" height="100%"
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    skinClass="components.skins.SxScrollerSkin"
    >
    <s:Group id="myGroup" width="100%" height="100%">
    <s:RichEditableText id="myRichText" >
    </s:RichEditableText>
    <!--- Do not set the height of the RichEditableText - since it seems to prevent the appearance of the vertical scroll bars -->
    </s:Group>
    </s:Scroller>
    With the following Actionscript to initialize, etc.
                textContainer = new SxBorderContainer(name);
                textContainer.dx = dxAvailable;
                textContainer.dy = dyAvailable;
    scroller = new SxScroller();
    scroller.move(dxPadding,dyPadding);
    scroller.dx = dxAvailable
    scroller.dy = dyAvailable;
    textContainer.addElement(scroller);
    var richText:RichEditableText;
    richText = scroller.richText;
    richText.toolTip = toolTip;
    richText.enabled = true; // required for mouse click capture
    richText.selectable = true; // required for mouse click capture
    richText.width = dxAvailable
         var textFlow:TextFlow = TextFlowUtil.importFromString(textFlowString, WhiteSpaceCollapse.PRESERVE);
          richText.textFlow = textFlow;
    And the following code to catch events:
                    richText.addEventListener(FlowElementMouseEvent.MOUSE_DOWN,userMouseEvent);
                    richText.addEventListener(FlowElementMouseEvent.MOUSE_UP,userMouseEvent);
                    richText.addEventListener(FlowElementMouseEvent.CLICK,userMouseEvent);
    Here's the problem.   If I have embedded images in the TextFlow that is imported into the richText, I only catch "some" mouse clicks.  It's hard to know, but it seems that only mouse clicks into white space (between paragraphs) are caught.  Mouse up and down are caught, but not "click".  Very puzzling.
    TextFlow like this:
        <TextFlow>
          <div color="#442222" fontFamily="Times New Roman" fontSize="20" paragraphSpaceAfter="15" textIndent="15">
            <p>
              <span>
                Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do:  once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without pictures or conversation?'
              </span>
            </p>
            <p>
                  <span>So she was considering in her own mind</span>
                  <img source="assets/library/alice/images/White Rabbit.png" height="auto" width="auto" float="left" />
                   <span> (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.</span>
            </p>
    If there are no embedded imags, I get all clicks exactly.
    Is it a bug?  Am I missing something? 
    Thanks,
    Oz

    Thanks for the answer. First I need clicks anywhere in the RichEditableText (no links or images). I use the selection manager to find the exact word that was clicked.
    The next step would be to capture clicks on links and images.
    I have tried using MouseEvent and had the same result (or worse) as FlowElementMouseEvent.  I will go back and retest with your suggestion.
    Oz
    Result of retest:
    I catch clicks only over images embedded in the TextFlow.  I catch only mouse up/down over text - both MouseEvent and FlowElementMouseEvent.
    Puzzling.  Where are the clicks going?

  • Handling Mouse Event

    How to access x and y co-ordinates when a mouse's left butto
    is clicked upon a JPG file whichis placed on a stage, so that we
    can view the jpeg contents on the stage?
    Please can anyone please send code to my mail.

    in the code that Dave has posted above "e" represents the
    event, event objects have properties, one of which (two actually)
    named 'target' represents the object being clicked - eg. the
    Display Object "myImage" - which has a properties called mouseX and
    mouseY, you can access these properties to display the coordinates
    relative to the scope of the Display Object - however 'how' you
    display the value is a different matter, if you want to place the
    'on screen' for the user, you should add one or two dynamic
    textFields to you file that you can then assign the values to for
    display. so lets assume you've done so, and the instances are named
    xText and yText (remember to embed the font in the fields) - so
    then to display the values you would use something like:
    function mDown(e:MouseEvent) {
    xText.text = e.target.mouseX;
    yText.text = e.target.mouseY;
    }

  • Reasons to create a new class to handle mouse events

    Hi,
    I have a class which is very large (3000+)..anyway, some of the mouseEvents that I handle (mouseClicked, etc)...are quite large. I was thinking about separating these into a new class, but I am not 100% sure of the benefits...any suggestions, ideas?
    Thanks

    If you look at Sun's classes you must agree that they are cohesive. Each one you have mentioned also has the requirement of implentation of an object--it kind of defeats the purpose of the api if it takes 8 to 10 classes to implement a JTable doesn't it?.
    You must consider carefully this from the previous post by UlrikaJ: "If the class is cohesive, that is encapsulates one idea, it may be better to keep everything together. But if it's a junkyard of disparate ideas that didn't fit elsewhere..."
    I will say this, that most classes that I have encountered that go beyond a few hundred lines of code fit into the "junkyard of disparate ideas", in some cases I would categorize them as "junkyard of desperate ideas", but that is another story all together.
    If you class is highly cohesive, then you have a good class, but if not you should break it appart for readability, maintainablity, and correctness.

  • Firefox mouse event not behaving the same on PC and Mac computers

    I use the FCKEditor and having a very strange problem. When I click on the FCKEditor's editing area, the keyboard gets disabled untill I click the mouse somewhere outside of the editing window. The problem only happen on Firefox (3.6.10) on Mac computer (Snowleopard 10.6.4). Doing exactly the same steps on PC works without any problem.
    What I want to know:
    - Is it possible that the Firefox on Mac is different than the PC in handling mouse events? Or some other areas?

    Sounds more that Firefox is treating that editor area as read-only.
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]

  • Handling keyboard events in applets?! Possible?!

    Hello,
    I wrote a little game that uses keyboard handling events. It is an applet that can also standalone as an application. When i run the program as a standalone application, it handles keyboard inputs fine. ie...i can press the left and right arrow keys and something happens.
    But when i run my program as an applet in a web browser, the applet starts up correctly but does not handle any keyboard events. It only handles mouse events. For instance, if i press the up and down arrow keys, the browser window scrolls up and down!!! And the up and down arrow keys have a specific purpose in my applet.
    QUESTION: how do i get my applet to accept keyboard inputs such as UP,DOWN, LEFT, RIGHT?

    Hmm something went wrong w/ my post so i hope this doesnt show up twice.
    Hey thanks a lot for helping me out. The applet/application is large so here is the main() method and the keyboard event handling class code. My question is how come the keyboard events get properly handled when i run it as a standalone application, but keyboard events go to the browser when i run it as an applet? I would post my entire code but it's over 1000 lines and spread out over 8 files. hehehe.
    Here is main():
      public static void main(String[] args)
          MyProgram applet = new MyProgram();
          applet.isStandalone = true;
          JFrame frame = new JFrame();
          frame.setTitle("Physics: Kinematics");
          frame.getContentPane().add(applet, BorderLayout.CENTER);
          applet.init();                        // initialize the applet inside frame
          applet.addKeyListener(kbHandler);     // kbHandler is a keyboard handling object
          applet.start();
          frame.setSize(APPLETWIDTH,APPLETHEIGHT);
          Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
          frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
          frame.setVisible(true);
          // private inner class to terminate the Application when frame closes
          frame.addWindowListener(
            new WindowAdapter()
                public void windowClosing(WindowEvent e)
                    System.exit(0);
          frame.show();
       }"kbHandler" is the keyboard event handling object. It gets initialized in the applet.init() method.
    kbHandler = new BMkeyboardHandler();And here is the keyboard event handling code:
    // ===== keyboard event handler ===========
       private class BMkeyboardHandler implements KeyListener
            public void keyPressed(KeyEvent e)
                pushedKey = e.getKeyCode();
                // General administrative key actions
                if(pushedKey == KE.VK_H)
                    actionArea.toggleHelpMenu();
                    actionArea.repaint();
                else if(pushedKey == KE.VK_C)
                    actionArea.toggleCtrlMenu();
                    actionArea.repaint();
         }So there it is. Again, the program handles events fine as a standalone application. But running it as an applet in a browser (and even the appletviewer) doesnt let me handle keystrokes.

  • How to handle Mouse listener (Clicked) in JGraph

    Hi Guys,
    I am doing a project using JGraph with SWING.
    How to handle Mouse events such as pressed or Move using JGraph in each of the node (Vertex&Edge).I have already tried a example which is presented in JGraph manual. But unable to fix the problem.Kindly help me

    i have not used JGraph before, but i think its event handling is equal to anyother swing component. so what exactly is the problem you can't solve?

  • How to handle doubleclick mouse event in java

    i want to handle double click mouse event in java
    i use getClickCount() function
    but i want that on onetime click show othere windows
    and on doubleclick show diif. window
    but problem is that onetime is occuer always if u click doubleclick

    Maybe post some code so we can see what, if anything, you are doing wrong.
    Examing the results of a call to getClickCount() is the correct way to detect a double click.

  • How Keyboard & Mouse Events are handled in java?

    Hi
    How Keyboard & Mouse Events are handled in java?
    Kindly brief, how a key typed in the keyboard is sensed and it is entered in JTextField?
    or
    Pls. give me some links.
    Am going to send the events from external device (like keyboard) to OS and from that I need to capture that event in Java Swing?
    Pls. drop in a bit. So that it will be helpfull to me.
    Thanks in advance,
    bee

    Actualy am very much aware of using KeyListener and MouseListener. I am in need of internal details,
    how typing a key in keyboard is captured by KeyListener? How the event is passed to java swing and and it is fired to keylistener.
    Pls. help me.
    Thanks
    bee

  • Is it possible to handle multiple events using Jscript for a button in Apex

    Hi,
    I've application wherein in one of the pages for a button, I need to trigger 2 events as: 1. redirect to a new page upon 'click' of the button
    2. display a set of values on 'mouse over' that button.
    I'm able to handle both separately, but not in one button. I would like to know if there is any limitation in Apex that we cant handle multiple events? Currently I've put a text item near the button, and called the Jscript for mouse over event in that as a temporary workaround. Can someone let me know if this is feasible? If not any other alternative to handle this?
    Thanks in advance,
    gsachidh

    Hi Gsachidh,
    well interesting problem you're facinng. Indeed, it can't be specified using the 'Button Attributes' So we have to come up with an workaround.
    A quick en dirty solution would be to specify it with the 'Optional URL Redirect options'. In a normal button, with processing on same page, this would be 'no target'. but in case of additional things to be done this can be used, using an target URL. I used this many times, in example with popUp windows for refreshing the caller object when changes are made. In your case we have to add next to the href an onmouseover event. this can be done with;
    Target set to => URL
    URL - target => javascript:doSubmit('<button_name>');" onMouseOver="javascript:showTooltip('tooltip');"
    Here the " is the key, letting ApEx know the target (href) is doSubmit('<button_name>'), just like when no target would be specified and adding a new javascript event; onMouseOver.
    Although this is a dirty solution in my opinion, it is the best i could come up with. I have another idea in how to do this, that is by adding this event dynamically with javascript with an addEvent. But i don't have an example at the moment for this scenario.
    Simon
    Message was edited by:
    S1M0N

  • Reg : Cross browser issue while handling LOV event on KeyFlexFeild

    Hi OA Gurus,
    We are encountering issues on R12.0.6, JDev 120Rup6.
    We have the following test case and code changes.
    Requirement:
    We have OA page where we have one KeyFlexFeild item and a normal LOV. Page items are part of one AM and LOV is in another AM.
    The requirement was to make LOV dependent on keyFlexfeild. Test case is mentioned as per following flow.
    1.     User changes cost center segment of Accounting Flex(Key flex) using Cost center LOV.
    2.     Another LOV in the same page should be dependent on new value of cost center as modified in step 1.
    Solution Implemented:
    Describing in the 3 steps
    1) Here the KeyFlexFeild is expense account. Whenever User changes any segment, we handle
    ‘lovValidate’ and ‘lovUpdate’ events on KeyFlexFeild in processFormRequest of controller.
    2) Retrieve the value of cost center segment using getSegmentsQualifiedBy(), Update corresponding VO attribute of the LOV query parameter.
    3) Forward the request to current page so that LOV will have modified value with updated query.
    4) Forwarding to current page is must because LOV is built with another AM and will loaded only when page is built.
    Issue:
    This works fine on internet explorer. When trying to run the same in Mozilla we have following issue
    1) User modifies one of the segments of expense account and make a tab – out
    2) Now the page refresh happens
    3) Now in the same page no other LOV or no other button works. He can’t click on any button for submit or cancel.
    LOVs will not open even after clicking on it.
    Code changes:
    //Step1 – Handle LOV events
    String source = pageContext.getParameter(SOURCE_PARAM);
    String eventType = pageContext.getParameter(EVENT_PARAM);
    if(source !=null && eventType != null) {
    if(source.startsWith("Acct") && eventType.equals("lovUpdate") || eventType.equals("lovValidate") ) {
    KeyFlexfield flex = (KeyFlexfield)lkff.getAttributeValue(OAWebBeanConstants.FLEXFIELD_REFERENCE);
    // Step -2 Updating the corresponding VO attribute for LOV to get the modified the value
    Segment[ ] segmentL = flex.getSegmentsQualifiedBy(FA_COST_CTR");
    CostCenterValue = segmentL[0].getValue().getValue();
    if(CostCenterValue != null ){
    sampleViewObject.getCurrentRow().setAttribute("ToCostCenter",CostCenterValue);
    OAFormValueBean formValueBean = (OAFormValueBean)webBean.findIndexedChildRecursive("ToCostCenter");
    if(formValueBean != null)
    formValueBean.setValue(pageContext, CostCenterValue);
    OAMessageLovInputBean formValueBean1 = (OAMessageLovInputBean)webBean.findIndexedChildRecursive("ReceivingApprover");
    if(formValueBean1 != null)
    formValueBean1.setValue(pageContext, null);
    else
    sampleViewObject.getCurrentRow().setAttribute("ToCostCenter",null);
    //Step 3 – Forward the request Current Page again
    pageContext.setForwardURLToCurrentPage(null, true, ADD_BREAD_CRUMB_YES, (byte)0);
    We have following questions.
    a)     Solution implemented by us is correct ? or we have to implement it in another way ?
    b)     Is OA version mentioned above supported on Mozilla browser version 3.x ? This issue is not occurring on Mozilla 1.x while running from JDev.
    Please let us know if any additional details required.
    Thanks for help in advance.
    Edited by: user774130 on Dec 15, 2009 2:27 AM

    Hi,
    It seems that you have not noticed that this forum is not for posting product-related questions/problems....
    So , this might be the correct forum....
    Java Server Pages (JSP)
    Sim

  • Using activex component in openGL app:  mouse event issues.....

    i'm trying to get the Flash ActiveX control to work in an
    OpenGL app. so far i've managed to get the bitmap data and map it
    to a texture succesfully. but i'm having problems getting the mouse
    interaction to work.
    i get an hWnd from IShockWaveFlash's IOleWindow. when i send
    mouse messages to it, the mouse is interpreted correctly by
    actionscript (for example, i have a custom mouse cursor tracking
    _xmouse, _ymouse which works fine).
    however, buttons do not behave correctly. rollover is
    erratic, and only in rare circumstances can i get a button's
    onPress handler to fire.
    am i sending the mouse events in correctly? any ideas of any
    other way to send them in?

    Thank you for you mail,
    After I read this article
    http://digital.ni.com/public.nsf/3efedde4322fef198​62567740067f3cc/610540bb3ea4ebdd862568960055e498?O​penDocument
    I realized that ActiveX events are not supported on CVI 5.01 at all since
    its introduced as a new feature of CVI 5.5
    "Azucena" wrote:
    >Daniel,>>Have you tried the function CA_RegisterEventCallback function?
    (I am using>CVI 5.5)>>This function is used by the functions generated by
    the Automation>Controller Instrument Driver Wizard.>It is not intended to
    be used directly.>>It basically registers a callback for an ActiveX Automation
    server object>event.>To register the callback, you must specify the CAObjHandle
    of the server>object from which you want to receive events.>>W
    ith CVI 5.5,
    there is an example for IE with Active X under the>samples/activeX directory.>>Hope
    this helps,>>Azucena>>"Daniel Bentolila" wrote in message>news:[email protected]..>>>>
    Has anybody tried to capture an ActiveX component event in a CVI>application>>
    ?>>>> for example I've created a new instance of the Internet Explorer>application>>
    from the CVI , using the ActiveX Automation controler I choosed the>Microsoft>>
    internet controls then I selected IWebBrowser2 and the IWebBrowserEvents2>>
    classes and generated the fp file for the CVI.>> Under the the IWebBrowserEvents2
    I see there are events fucntion for>example>> OnQuit, and I wanted my CVI
    app. to attach the quit event when the user>closes>> the IE window.>> Now
    at this point I expected to find some mechanism that let me to install>>
    some callback function where I can put my customised code to the quit>event,>>
    somehow I have to tell the IE to call my function whenever the OnQuit>callback>>
    fun
    ction is attached and I don't know how to do this.>>

  • How to handle key events in iphone

    I want to be able to detect physical keyboard (e.g. bluetooth) events in an iOS app.
    In Mac, there is a class NSEvent which handles both keyboard and mouse events, and in ios (iphone/ipad) the counterpart of NSEvent is UIEvent which handles only touch events. I know ios API does not provide this functionality, but how can i handle key events in iphone???

    in my application header part of the page is common of all page. header.jsff contains comandmenuItem named "proceduralhelp". if I click proceduralhelp a pop up opens .
    in my login page when first time I open popup and press escape popup is not closing.
    rest of the cases after login escpe will cose the popup.
    only on the loginpage that to for the first time it is not closing when pressing up on escape key. (then we click on close button. and once again open the popup in loginpage now if we press escape it works).
    Thanks,
    Raghavendra.

  • Having picked up a mouse event, pass it to parent component.

    This is further to my table cell hover, which is otherwise working.
    I track the mouse accross the table using an invisible child component, and when the mouse leaves it, move the child onto the new cell position.
    The problem is that, while the mouse is over the invisible component, that component is grabbing all the mouse events. My table also wants to detect mouse events (though it's interested in clicks).
    The obvious thing is, after they've been dealt with and the child component level, to transfer the events to the table (having mapped the mouse coordinates). However all the processEvents methods in components like JTable are protected.
    I suppose I could extend JTable and add a method to get arround protected, but that's nasty, especially since a lot of my JTables are already subclassed.

    I had to do just this. I have JLabel's in a JPanel. The JPanel is in a LayeredPane. When I mouse over the JLabels, they grab the mouse events... which I don't want. I want the LayeredPane to get it.
    So in the JLabel, I do:
          * Don't send to parent what you don't have to. Things like tooltips will
          * be broken if this is not handled carefully...
         public void mouseClicked(MouseEvent e) { }
         public void mouseMoved(MouseEvent e) { }
         public void mouseEntered(MouseEvent e) { }
         public void mouseExited(MouseEvent e) { }
         public void mouseReleased(MouseEvent e) { machine.dispatchToParent(e);}
         public void mouseDragged(MouseEvent e) { machine.dispatchToParent(e);}
         public void mousePressed(MouseEvent e) { machine.dispatchToParent(e);}(the "machine" above is a JPanel). Now in the JPanel, aka "machine", I do:
    Point point; int comp_x, comp_y; // for component with respect to this machine
    public void dispatchToParent(MouseEvent e) {
         point=((JComponent)e.getSource()).getLocation();
         //System.out.println("Dispatching: " + e.getX() + " " + e.getY());
         //System.out.println("Component position: " + ((JComponent)(e.getSource())).getLocation());
         if (e.getButton() > 0) MsgIFrame.println("ME at: " + comp_x + "," + comp_y + " button: " + e.getButton() );
         if (e.getButton() > 1) {
              popup(e);
              return;
         comp_x=(int)point.getX(); comp_y=(int)point.getY();
         comp_x+=this.getX(); comp_y+=this.getY();
         e.translatePoint(comp_x, comp_y);
         room.getLayeredPane().dispatchEvent(e);
    }Above, the "room" is a JInternalFrame with a LayeredPane inside it, as you can see. I do a little translating so the LayeredPane gets the event in its coordinate space, not those of its Components.

Maybe you are looking for

  • Do I have to change file associations in Windows 7 one at a time?

    I changed my ancient Paint Shop Pro for Elements 11 but the file associations are still PSP. I can change them one at a time but that will take forever! Is there a way to associate all the appropriate files in one go?  I managed it many years ago in

  • End loop then advance to next frame

    I'm building a presentation and I'd like it if I could set up the following: There's a looping animation. It starts and ends with a solid transition to something else. However, I'm building this for a separate presenter (seveal, in fact) and I don't

  • New to SOAP - How to create SOAP message for the SOAP described

    Hi Friends, Im bit new to SOAP-JAVA interactions. I have an SOAP describing POST /abc/WebSrevices/MyService.asmx HTTP/1.1 Host: 127.0.0.1 Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/BillingAddressValid

  • Itunes won't sync, won't backup, status of all devices are "other"

    computer is a mac mini 2006 1.66 ghz core duo, 2 gb of ram, macmini 1,1. os x 10.6.8 , itunes 11.4 devices are running ios 8.1 , they can sync and backup perfectly fine to my mac book pro. but they haven't been able to sync or backup to my mac mini f

  • Problems while installing OAS 4.0.8.1

    I am experioencing problems during the installation of OAS4.0.8.1 under RedHat 5.0. In the same machineis installed an Oracle8.0.5 RDMS After i have been propted for Node Manager Listener Settings during the installer is analyzing dependencies i have