13 Replies Latest reply: Apr 9, 2014 6:06 AM by Rudi Strasser RSS

How to stop page refresh when hit enter button from rich:inputNumberSpinner field?

Eswara MoorthyNEC Newbie

Hi,


I use rich:inputNumberSpinner tag.

 

The problem is :

 

I set cursor focus to inside of rich:inputNumberSpinner field, then i hit the enter button from my keyboard, that time page will be automatically refresh.

But i don't need page refresh when i hit the enter button from my keyboard.

 

spinnerTagTest.jsp


<f:view>
    <html>
       <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">          
       </head>

   <body>
      <h:form id="SpinnerForm">
           <rich:panel id="SpinnerPanel">                
             <rich:inputNumberSpinner id="spinnerField" value="" maxValue="23" inputSize="2"/>                                         
           </rich:panel>
      </h:form>
 </body> 
</html>
</f:view>

I also used rich:hotKey for inputNumberSpinner field. But Page refreshed.


<rich:hotKey key="return"
             selector="#spinnerField"
             handler="event.stopPropagation();event.preventDefault();
             return false;"/>


And i test anotherway using javascript, but page refreshed.


The specific tag and javascript is :

<rich:inputNumberSpinner id="spinnerField"  value="" maxValue="23" inputSize="2"
                         oninputkeypress="return stopPageRefresh();"/>

<script type="text/javascript">

    function stopPageRefresh()
    {
        alert("Stop Page refresh called");    
        return false;
    }
</script>



Here i use one alert message inside of stopPageRefresh().
But i hit enter button, first page refreshing and then alert message displayed.


Help me about this. Thanks in advance.