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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -