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: client side function selectValue() doesn't work before menu was opened

See original GitHub issue

Describe the defect When calling the SelectOneMenu widget function selectValue() before the menu was opened at least once, the function call fails.

Uncaught TypeError: Cannot read property 'eq' of undefined
    at c.selectValue (components.js.xhtml?…mefaces&v=10.0.0:20)
    at <anonymous>:1:45
selectValue	@	components.js.xhtml?…mefaces&v=10.0.0:20
(anonymous)	@	VM812:1

It seems like this.items in forms.selectonemenu.js:1114 is undefined in this case.

After opening the menu, everything works fine.

Reproducer Showcase for SelectOneMenu https://www.primefaces.org/showcase/ui/input/oneMenu.xhtml

Environment:

  • PF Version: 10.0.0
  • JSF + version: MyFaces 2.3.6
  • Affected browsers: ALL

To Reproduce Steps to reproduce the behavior:

  1. Open the SelectOneMenu showcase https://www.primefaces.org/showcase/ui/input/oneMenu.xhtml
  2. Execute the selectValue() function in the console for one of the menus, e.g.
PrimeFaces.getWidgetById('j_idt302:option').selectValue('Option1')
  1. If you open the menu, e.g. PrimeFaces.getWidgetById('j_idt302:option').show() and then execute 2. again, it works.

Expected behavior selectValue() should be able to select a value even before the menu was opened.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, Sep 2, 2021

I marked for Elite but its up to @sqores to implement.

1reaction
cnsgithubcommented, Jun 11, 2021

Thanks for the quick fix. I just tried it with a build that includes 5a5be48 and the selectValue() function now works as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

get selected value from selectOnemenu using javascript in ...
Open the page in browser, rightclick and View Source (or here on PrimeFaces showcase site). You'll see that the actual <select> element has...
Read more >
selectOneMenu and f:selectItem - Prime Community Forum
So basically: how do I create a selectOneMenu that doesn't have an item selected at the beginning and the submit button is only...
Read more >
h:selectOneMenu is setting null to bean propert... - JBoss.org
I used h:selectOneMenu inside popup modal panel(rich:popupPanel). Selected value of h:selectOneMenu does't pass to bean property.
Read more >
SelectOneMenu | PrimeFaces JavaScript API Docs
When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. When the...
Read more >
h:selectOneMenu javascript onchange problem — oracle-tech
i have 4 <h:selectOneMenu> lists 3 lists depends on the first one via ... <script language="javascript"> function disableOtherLists() { var ...
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