Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change selected item of selectonemenu primefaces by managedbean of javascript

I want to change the selected value of this selectOneMenu either by managed bean or javascript:

<p:selectOneMenu id="edit-article-famille" widgetVar="editFamille"
    required="true" requiredMessage="Veuillez choisir une famille"
    value="#{articlesMB.selectedFamille}">
  <f:selectItem itemLabel="selectionner famille" itemValue=""/>
  <f:selectItems value="#{articlesMB.listFamilles}"/>
</p:selectOneMenu>

How can I do it? In the primefaces user guide, they don't talk about that.

like image 351
atbegin-but Avatar asked Apr 01 '13 10:04

atbegin-but


1 Answers

You can set value of your p:selectOneMenu with widgetVar in JavaScript:

editFamille.selectValue(value);

value is value of selectItem.

Or in more recent versions of PrimeFaces via

PF('editFamille').selectValue(value)
like image 186
partlov Avatar answered Sep 18 '22 23:09

partlov