question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SelectOneMenu: not trapping the ENTER key.

See original GitHub issue

1) 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

  1. Create un form with un selectonemenu, commandButton and a defaultCommand what link to the button.
  2. Open values from selectoneMenu
  3. Press ENTER KEY in a value.
  4. 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nokiajavicommented, May 16, 2020

Thanks for the code! You’re great.

0reactions
nokiajavicommented, Jan 20, 2022

Thank you very @melloware, I will update it in my code.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found