SelectOneMenu: not trapping the ENTER key.
See original GitHub issue1) Environment
- PrimeFaces version: 8.0
- Does it work on the newest released PrimeFaces version? Version? No
- Does it work on the newest sources in GitHub? No
- Application server + version: Apache Tomcat 9.5
- Affected browsers: All
2) Expected behavior
When a form has a p: defaultCommand, the p: selectOneMenu component should not execute the defaultCommand action when you press the ENTER key in the selectonemenu value list
3) Actual behavior
the p: selectOneMenu component, when pressing ENTER KEY on a value in the list, the action of the button associated with the defaultCommand is executed, this only happens if the component does not have the filter = “true” property. If there is no defaultCommand inside the form, the component works correctly.
4) Steps to reproduce
- Create un form with un selectonemenu, commandButton and a defaultCommand what link to the button.
- Open values from selectoneMenu
- Press ENTER KEY in a value.
- The form is sended
5) Sample XHTML
<h:form id="form">
<p:selectOneMenu>
<f:selectItem itemValue="1" itemLabel="uno"/>
<f:selectItem itemValue="2" itemLabel="dos"/>
<f:selectItem itemValue="3" itemLabel="tres"/>
<p:ajax event="change"></p:ajax>
</p:selectOneMenu>
<p:defaultCommand target="boton1"></p:defaultCommand>
<p:inputText id="input" required="true" label="INPUT" />
<p:messages id="mesinput" showDetail="true" showSummary="false"/>
<p:commandButton id="boton1" ajax="true" process="@form" update="@form" validateClient="true" value="BOTON"></p:commandButton>
</h:form>
Case in which it does not fail
<h:form id="form">
<p:selectOneMenu filter="true" filterMatchMode="startsWith">
<f:selectItem itemValue="1" itemLabel="uno"/>
<f:selectItem itemValue="2" itemLabel="dos"/>
<f:selectItem itemValue="3" itemLabel="tres"/>
<p:ajax event="change"></p:ajax>
</p:selectOneMenu>
<p:defaultCommand target="boton1"></p:defaultCommand>
<p:inputText id="input" required="true" label="INPUT" />
<p:messages id="mesinput" showDetail="true" showSummary="false"/>
<p:commandButton id="boton1" ajax="true" process="@form" update="@form" validateClient="true" value="BOTON"></p:commandButton>
</h:form>
6) Sample bean
N/A
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
ENTER to TAB redirect - problem with <h:selectOneMenu>
I've redirected ENTER key to TAB key using by this working jquery method: $('*').live("keydown", function(e) { if (e. ... keyCode == 13 ||...
Read more >primefaces - issue #5690 - Google Code
There was an error obtaining the issue: {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null] ...
Read more >primefaces - issue #8043 - Google Code
4 demo images are placed inside theme jar which are not necessarily required for theme to work, they should be placed inside demo...
Read more >JSF form: using ENTER as TABULATOR key - Similar Threads
Other threads similar to JSF form: using ENTER as TABULATOR key ... Use of enter key in JSP page ... selectOneMenu value not...
Read more >Primefaces Selectonelistbox Change Event - ADocLib
The Enter key makes form submission so easy that users always tend to use it. ... issue I think that is a bug...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the code! You’re great.
Thank you very @melloware, I will update it in my code.