I have very specific requirement that uses JavaScript, JSF 2 and Ajax feature of JSF 2. I have a drop-down list with two values. Say A and B.
<h:selectOneMenu class="form-control" id="sampleList" value="#{beanName.tempValue}">
<f:selectItem itemLabel="Select value..." itemValue="0" />
<f:selectItem itemLabel="A" itemValue="a" />
<f:selectItem itemLabel="B" itemValue="b" />
<f:ajax event="change" listener="#{beanName.actionMethodToNavigate}" onevent="if (this.value=='0'){ return false;} else if (this.value=='a'){jumpToAhchor('#listItems');return false;}"/>
</h:selectOneMenu>
If the drop down value is "a" then user stays on the same page and anchors to other element down on the same screen using JavaScript. If the value is B then it calls bean method, which eventually navigates user to other screen.
I have tried to search many examples, and many suggest to put JavaScript in onevent attribute. But it does not work in my case and getting this console error in browser.