javascript - How to set selected value into p:selectOneMenu? -
i have p:selectonemenu
:
<p:selectonemenu styleclass="categorylist" filter="true" id="parentcategorylist" style="width: 200px" effect="fade" panelstyleclass="categorylistpanel" converter="#{categoryconverter}" widgetvar="categorylistwv" value="#{categoryservice.category}"> <p:ajax event="change" update="@this" /> <f:selectitem itemlabel="no parent" /> <f:selectitems var="currcateg" value="#{categoryservice.categories}" itemlabel="#{currcateg.name}" itemvalue="#{currcateg}" /> </p:selectonemenu>
i need set value via javascript. in web found solution:
widgetvar.selectvalue(value);
i apply case:
function addnewsubcategory() { var div = document.getelementsbyclassname("ui-state-highlight")[0]; var label = div.getelementsbytagname("label")[0]; var parent = label.innerhtml;//name of item, string if (parent === 'shop') return; categorylistwv.selectvalue(parent);//invoked, not set value alert(categorylistwv.getselectedvalue());//works correct alert(categorylistwv.getselectedlabel());//works correct openaddcategbtn();//open dialog p:selectonemenu located }
ps items in p:selectonemenu
objects. wrote converter them
Comments
Post a Comment