enter commanlink

UI Components for JSF
Post Reply
jlgarcia1977
Posts: 32
Joined: 18 Oct 2011, 18:21

25 Nov 2011, 10:57

Hi...

I have a page with several "commadLink" and I get to "hotkey" to run when you press enter the action of one particular.

Code: Select all

<p:commandLink 
				id="commnadLinkFind"
				action="#{beanController.find}" />
	  <p:hotkey bind="enter" handler=commnadLinkFind.click();" />
does not work.


I'm using Primefaces 3.0.RC1-SNAPSHOT, Mojarra 2.1.4 and deploying on Tomcat 7 / JDK 6.

Thanks in advance. Best regards

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

25 Nov 2011, 12:54

3.0M4 User guide states the following:
Note that hotkey will not be triggered if there is a focused input on page.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

jlgarcia1977
Posts: 32
Joined: 18 Oct 2011, 18:21

25 Nov 2011, 15:48

ok, fix the problem as
how do I remove the focus

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

25 Nov 2011, 20:05

sorry, i don't understand your response. Did you fix the problem? You might want to post your xhtml file here via Code button (while responding via editor).
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

jlgarcia1977
Posts: 32
Joined: 18 Oct 2011, 18:21

27 Nov 2011, 13:25

Sorry, my English is very bad and I use the google translator.

I have yet to code, because it is not how to make pressing "enter", you run the "action" of a "commandLink", I thought I could be with the "hotkey" but not work for me. Do not know if there is another possibility.

porthos
Posts: 122
Joined: 09 May 2011, 03:17

27 Nov 2011, 15:54

I'm not entirely sure what you're trying to accomplish. But you might find the following javascript hack works a bit more reliably, or predictably, than hotkeys:

Code: Select all

  <h:outputScript>
    function processFormKeyPress(e) {
      if (!e) var e = window.event;
      if (e.keyCode == 13) { // Enter key
        var targ;
        if (e.target) targ = e.target; 
        else if (e.srcElement) targ = e.srcElement;
        if (targ.nodeType == 3) // defeat Safari bug
          targ = targ.parentNode;
        if ( targ.nodeName == "TEXTAREA") return true; //ensure Enter works in textarea controls
        else {
          $('#commnadLinkFind').trigger('click');  // whatever action you want Enter to accomplish
          return false;  // disable further processing of the Enter key event
        }
      } else {
        return true;  // process all other keys normally
      }
    }
  </h:outputScript>

  <h:form id="myForm" onkeypress="return processFormKeyPress(event);">
     ...
  </form>
Last edited by porthos on 29 Nov 2011, 14:29, edited 1 time in total.
-------
PrimeFaces 3.4, Glassfish 3.1.2, Mojarra 2.1.6

jlgarcia1977
Posts: 32
Joined: 18 Oct 2011, 18:21

29 Nov 2011, 11:44

thank you very much.

porthos
Posts: 122
Joined: 09 May 2011, 03:17

29 Nov 2011, 14:45

Glad it's of use.
-------
PrimeFaces 3.4, Glassfish 3.1.2, Mojarra 2.1.6

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 61 guests