Need to clear h:messages on mouse click

I have a screen that is displaying a "Insert successful" message via an h:message tag when the user successfully saves data to the database. The user has requested that when they click on any field on this screen, they want this message to be cleared so they can then insert more data and not be confused by the message remaining displayed. So, I found some Javascript code that is supposed to be able to grab the id from rendered JSF tag and clear the contents. It's not working. The h:messages tag gets converted to a <span> tag in HTML and I'm not sure how to clear a <span> tag programatically. My Javascript onclick code is as follows:
function clearMessages()
document.forms[0].elements["thisForm:globalMessages"].value = "";
document.forms[0].elements["thisForm:globalMessages"] = null;
But it's telling me that the "thisForm:globalMessages" element does not exist. Even though that's the id of the <Span> tag, I'm trying to clear the contents of. Any ideas on whether what I'm trying to do is even possible??????
Thanks,
Mike

Use element.firstChild.nodeValue or element.innerHTML.
This is a Javascript problem rather than JSF problem though. For more detailed help and the future Javascript related problems, please use the forums devoted to Javascript. There are ones at webdeveloper.com and dynamicdrive.com.
document.forms[0].elements["thisForm:globalMessages"].value = "";
document.forms[0].elements["thisForm:globalMessages"] = null;Two comments though:
1) using forms[0] is dangerous, you should never rely on the ordering of the forms in the document. Just get the form by its name.
2) The <span> element is not a form input element. You should be using document.getElementById().
There are nice Javascript and HTML DOM tutorials at w3schools.com. I highly recommend you to go through that.

Similar Messages

  • Event Handlers of a mouse click

    In the simplest way possible please tell me how to do an event handler for a mouse click.
    private int clickCounter = 0;
    private void MyCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    if (Device1RB.IsChecked == true)
    clickCounter++;
    return;
    else if (RemoveRB.IsChecked == true)
    clickCounter--;
    return;
    else
    return;
    private void Switch_class()
    switch (clickCounter)
    case 1:
    //code here
    break;
    case 2:
    //code here
    break;
    case 3:
    //code here
    break;
    case 4:
    //code here
    break;
    case 5:
    //code here
    break;
    default:
    //code here??
    break;
    This is what I have and I apparently need an event handler for the mouse click. Also if there is an easier way to do what I want then please point me in the right direction.

    I still can't figure out why its not working.
    private int clickCounter = 0;
    private void MyCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    if (Device1RB.IsChecked == true)
    clickCounter++;
    return;
    else if (RemoveRB.IsChecked == true)
    clickCounter--;
    return;
    else
    return;
    private void Switch_class()
    switch (clickCounter)
    case 1:
    pic_1.Visibility = System.Windows.Visibility.Visible;
    break;
    case 2:
    pic_2.Visibility = System.Windows.Visibility.Visible;
    break;
    case 3:
    pic_3.Visibility = System.Windows.Visibility.Visible;
    break;
    case 4:
    pic_4.Visibility = System.Windows.Visibility.Visible;
    break;
    case 5:
    pic_5.Visibility = System.Windows.Visibility.Visible;
    break;
    default:
    //code here??
    break;
    That's what I've got.
    <Canvas x:Name="MyCanvas" HorizontalAlignment="Left" Height="391" Margin="130,20,0,0" VerticalAlignment="Top" Width="520" MouseLeftButtonDown="MyCanvas_MouseLeftButtonDown" Background="Transparent">
    <Rectangle Fill="White" HorizontalAlignment="Left" Height="391" Stroke="Black" VerticalAlignment="Top" Width="520"/>
    <Image HorizontalAlignment="Left" Height="34" VerticalAlignment="Top" Width="100" Source="Power.png" Visibility="Visible"/>
    <Image x:Name="pic_1" Height="42" Canvas.Left="152" Canvas.Top="70" Width="44" Source="2box.png" Visibility="Hidden"/>
    <Image x:Name="pic_2" Height="42" Canvas.Left="152" Canvas.Top="70" Width="44" Source="2box.png" Visibility="Hidden"/>
    <Image x:Name="pic_3" Height="42" Canvas.Left="152" Canvas.Top="70" Width="44" Source="2box.png" Visibility="Hidden"/>
    <Image x:Name="pic_4" Height="42" Canvas.Left="152" Canvas.Top="70" Width="44" Source="2box.png" Visibility="Hidden"/>
    <Image x:Name="pic_5" Height="42" Canvas.Left="152" Canvas.Top="70" Width="44" Source="2box.png" Visibility="Hidden"/>
    </Canvas>
    This is the canvas...Is there something blatantly obvious that I'm missing?

  • How can I capture mouse click events on BSP or Web Dynpro ABAP Screen

    hi Guys,
    Currently we have a user inactivity problem,
    the requirement is: if user is clicking on BSP/Web Dynpro ABAP screen, he/she is considered active. so we need an mechanism to capture the mouse click event.
    Using Firebug, we found that this js is in the iframe which contains BSP/web dynpro scrren: /sap/public/bc/ur/nw5/js/languages/urMessageBundle_en.js
    we want to find this js file & put in some javascript code to track user's mouse click, but i cannot find it on server.
    while in ie if we type http://host:port/sap/public/bc/ur/nw5/js/languages/urMessageBundle_en.js
    this file can be downloaded, means this file is there.
    Any one can help on this issue? find the js file or another way to capture the mouse click event.
    Thanks a lot with points!

    Hi  Feng Guo,
                        We can not capture mouse click events on Web Dynpro ABAP Screen . I am not sure about BSP. But as for as I know the portal keep active the iViews until unless mouse clicks happens.
    But for your problem I think you can get solution by setting iView Expiration to some more time period.
    Regards,
    Siva

  • [svn:fx-trunk] 13362: List mouse click selection bug fix

    Revision: 13362
    Revision: 13362
    Author:   [email protected]
    Date:     2010-01-07 17:22:41 -0800 (Thu, 07 Jan 2010)
    Log Message:
    List mouse click selection bug fix
    SDK-24963 - Mouse click is ignored by List if  allowMultipleSelection="true" in some cases
    Updated setSelectedIndices to perform the single index equality check if selectedIndices has only one index.
    QE notes: None
    Doc notes: None
    Bugs: SDK-24963
    Reviewer: Ryan
    Tests run: checkintests, List
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24963
        http://bugs.adobe.com/jira/browse/SDK-24963
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/List.as

  • Detecting mouse clicks in editable cell of JTable

    Hi everyone :)
    I thought that this question might have been asked before, but I have searched the forums extensively and have not been able to find the solution.
    What I want to achieve is to detect single and double mouse clicks on JTable cells (that are editable).
    For example, I have a JTable and there exists within it an editable cell. If the user clicks on it once then that cell goes into edit mode, and the user can type directly into the cell. I have already successfully implemented this.
    However, what I also want to do is detect a double-click so that I can pop up a dilaog that shows a list of default values that the user can select.
    So here is what I want;
    1. User clicks on the cell once.
    2. Cell moves into edit mode.
    3. If the user clicks again within a certain time interval then cancel edit mode and pop up a dialog containing values that the user can select from.
    I think that to do this I need to be able to detect mouse clicks on the cell that is currently being edited. So far I have been unable to discover how this is done. I have even tried extending JTextField to get what I want, but with no luck.
    Any help would be greatly appreciated.
    Kind regards,
    Ben Deany

    Thanks for the reply.
    Unfortunately, it is not possible to call 'AddMouseListener()' on a cell editor. You are only able to call 'addCellEditorListener()' and that only allows two events to the broadcast (edit cancel, and edit stop).
    Ben

  • JOptionPane's message dialog over JDialog not recognizing mouse click

    I have a JOptionPane's message dialog like JOptionPane.showMessageDialog() which comes over a JDialog. When I try to click the OK button of this message dialog, nothing is happening. But, Enter key and Escape keys are working on it.
    Can any one give a solution?

    Hi,
    here are the steps how it goes.
    Step 1:
    private void generateMessageDialog(
            String message,
            int messageType,
            String messageTypeText,
            Component parentFrame)
            JOptionPane optionPane = new JOptionPane();
            optionPane.setMessage(message);
            optionPane.setMessageType(messageType);
            JDialog dialog = optionPane.createDialog(parentFrame, 
    messageTypeText);
            dialog.show();
    }If an exception occurs while connecting to my server, this method will be called to generate an error dialog.
    I have another thread which monitors the connection to server every 2500 ms. If the connection is lost, this thread will automatically generates a logon dialog. This dialog is a custom dialog that contains login fields.
    Step 2:
    public void run()
            int previousState = -1;
            while(previousState != CErrorCodes.SESSION_INVALID && previousState != CErrorCodes.NO_CONNECTION_TO_SERVER)
                int currentState = isConnected();
                // Check if a logoff action is pending
                if (currentState == CErrorCodes.REQUEST_SUCCEEDED)
                    if (getClientController().isLogOffPending())
                        break;
                previousState = currentState;
                try
                    sleep(2500);
                catch (InterruptedException e)
                    break;
    // generate the logon  dialog
            getClientController().getLogOnDialog();
    }If step 2 is executed before step 1, then the dialog generated by step 1 will come over the logon dialog generated by step 2. In this case, the ok button of the dialog generated in step 1 will not recognize mouse click. but enter or escape works. Both the dialogs are modal.
    Please let me know if you need furthur info. I look forward for your rep.
    Edited by: MallikMajety on Nov 8, 2007 6:02 AM

  • Reset the html:messages during the click of clear button ???

    Hi,
    When i click the clear button i need to clear the <html:messages>
    that has been populated below the form??? How to do this???
    Please provide a solution for this???
    Thanks,
    JavaCrazyLover

    No replies as yet....

  • Need a shortcut to "Allow pages to choose their own colors, instead of my selections above option preference" I know where it is and how to use it but I have to go through 7 mouse clicks to change it, then a few minutes later change it back. I also k

    Need a shortcut to "Allow pages to choose their own colors, instead of my selections above option preference" I know where it is and how to use it but I have to go through 7 mouse clicks to change it, then a few minutes later change it back. I also know the sequnce is alt t, alt o, alt c, alt a, then ok, ok. Got to be a way to make a one key short cut for this. I use a black background to reduce eye strain, but about 10% of the webpage I go to can't be send with black so I have to go into tools and hit 6 or 7 things to chnage it then after through with webpage have to do it all over at Not allow webpages to have own color. Very very cumbersome.
    == This happened ==
    A few times a week
    == made that way

    https://addons.mozilla.org/en-US/firefox/addon/toggledocumentcolors-198916/
    The above addon will solve your problem.
    Shortcut to toggle user color/page color :- Ctr+Shift+C

  • I try to open Acrobat I get a message that I need to register the product. I click on register and after about a minute, I'm told that I don't have an internet connection. My internet connection is working fine. In fact I registered Acrobat Pro XI using m

    I try to open Acrobat I get a message that I need to register the product. I click on register and after about a minute, I'm told that I don't have an internet connection. My internet connection is working fine. In fact I registered Acrobat Pro XI using my account, but the program itself will not recognize it or allow me to use the software. What do I do?

    If you already registered, then there is no point to trying to do so again. Simply dismiss the dialog.
    Mylenium

  • I got this message when I click on a song: you are about to start playback. Do you want to clear the 722 songs previously added to up next?

    I got this message when I click on a song: you are about to start playback. Do you want to clear the 722 songs previously added to up next?

    J.danquah wrote:
    "You are about to start playback. Do you want to clear the 312 songs previously added to Up Next?" how do you remove this from your ITunes?
    You can remove "this" (display of the Up Next list) by going to View > Hide Up Next in iTunes' menu.
    J.danquah wrote:
    would it delete 312 songs if you clck clear songs?
    No.  It would simply remove them from the Up Next list.

  • I recently backed up my iphone to itunes, when after backing up a message showed that I needed to update my iphone. I clicked ok, and after updating, it said I had to restore my phone to its factory settings. I cannot find where it backed up pictures

    I recently backed up my iphone to itunes, when after backing up a message showed that I needed to update my iphone. I clicked ok, and after updating, it said I had to restore my phone to its factory settings. I cannot find where it backed up all of my pictures from my phone.

    If you backed up the device, all the data is in the backup. Restore the backup.
    A better question is why would an intelligent person not copy the pictures from the device to the computer regularly, especially before attempting an update, as the device is designed to be used?

  • HT201210 I downloaded the latest update to itunes.  I am now getting a message that my ipod is on recovery mode and needs to be restored.  When I click to restore, it says it does not recognize the device.

    I downloaded the latest version of itunes.  I am now getting the message that my ipod is in recovery and needs to be restored.  When I click to restore, it says it does not recognize this device.  Now my ipod is frozen with an image of a cord and an arrow pointing toward the itunes icon.  All was working fine before the download!

    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • How do I fix error message "This document contains a link to an asset being upsampled. You should resize it smaller or right-mouse click on the asset in the Assets panel to see additional options." Which asset is it?

    I ab in Muse. How do I fix error message, This document contains a link to an asset being upsampled. You should resize it smaller or right-mouse click on the asset in the Assets panel to see additional options.

    You should ask in Help with using Adobe Muse CC
    This Cloud forum is not about using individual programs
    This Cloud forum is about the Cloud as a delivery & install process
    If you will start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • Every time I start my computer I get a message that cloud printing has crashed & needs to restart: ok---cancel. I click ok and nothing happens, so now it does not work.

    every morning when I boot up I get an error message. Google cloud has crashed and needs to reboot: ok--cancel. I click ok and nothing ever happens. So I click the "X". help and I need to add another printer to cloun and cab not get it to add? Why?
    Henry 317-418-6544
    [email protected]

    Jeff
    No solution I am afraid apart from what you have found. I occasionally have to completely re-install all of the apps as well. Same here, it happens after I reboot the system, if I keep it running then I am good.
    Very early Mac Pro 2 x 2.66  Xeon, 8GB, ATI Radeon HD 4870 and 10.7.5
    It is beginning to drive me mad.
    Regards
    Paul

  • My ipad has a message that i need to  back up to Icloud that won't clear and let me access any other apps or settings?  how do i clear this message?

    My ipad has a message that i need to  back up to Icloud that won't clear and let me access any other apps or settings?  how do i clear this message?

    Welcome to the Apple Community.
    The first back up to iCloud may take some considerable time. Just how long isn't really possible to say without knowing how much is in your back up and your connection speed.

Maybe you are looking for

  • A Java program that runs automatically at a given time of day

    Okay Iam at the ending stages of a Java Assignment that is a MySql database, Hibernate for Mapping with a Java Server Faces front-end. All I need to do now is send emails at set time every week. Normally I know what to search for but frankly Iam stum

  • Can I use an external hard drive on my iPad 3

    Is there anyway I can use an external hard drive on my iPad 3, as I have lot of work I need to save.

  • Multiple Linux JComboBox drops in the same position

    Following program create two similar JComboBox dropdown, and in Linux, when it runs, it works weirdly. If I first click first dropdown (s1), then later when I click second one (s2), dropdown part still appears under the first component. import java.a

  • Using AIA for Error Handling. Logging and Notification Services

    hi, In our project we usie OSB and BPEL for integrating different applications. There is a suggestion that we should use AIA to just use the Error Handling, Logging and Notification services from AIA. I am not sure about this use case, as most of the

  • IChat suddenly fails

    I can connect to a video conference but only for a few minutes, then my airport signal fails, and obviously my video conference fails too. although im not entirely sure that airport goes out 1st or if the conference fails 1st and causes the airport t