'Primefaces keydown, keyup Event on SelectoneMenu not working
i need to get the Key Value from a Primefaces Selectonemenu after Tab or Shift Tab is beeing pressed. Unfortunately the onkeydown, onkeyup attributes from this element does not work. Is that a bug and if so, is there a workaround for this? Thank u very much in advance.
In this example im just trying to see if an alert box is beeing called:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>PrimeFaces check SelectoneMenu</title>
<h:outputStylesheet library="webjars"
name="primeflex/2.0.0/primeflex.min.css" />
<style type="text/css">
</style>
</h:head>
<h:body>
<h:form>
<p:selectOneMenu id="option" onkeydown="alert('key down pressed')"
value="#{selectOneMenuView.selectedOption}" filter="true" filterMatchMode="contains">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem itemLabel="Option1" itemValue="Option1" />
<f:selectItem itemLabel="Option2" itemValue="Option2" />
<f:selectItem itemLabel="Option3" itemValue="Option3" />
<f:facet name="footer">
<p:divider styleClass="p-mt-0" />
<h:outputText value="3 options" style="font-weight:bold;" />
</f:facet>
</p:selectOneMenu>
</h:form>
</h:body>
</html>
Here is my pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>CheckPrimefaces</groupId>
<artifactId>CheckPrimefaces</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<servlet.version>3.1.0</servlet.version>
<jsf.version>2.2.15</jsf.version>
<primefaces.version>6.1</primefaces.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<tomcat7-maven-plugin.version>2.2</tomcat7-maven-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>primeflex</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<!-- JSF -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
<scope>compile</scope>
</dependency>
<!-- PrimeFaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>11.0.0</version>
</dependency>
</dependencies>
</project>
This Programm is run on Eclipse in a tomcat v7 Live Server.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
