I'm trying to add dynamically an item in a SelectOneMenu('Raison') within an editable dataTable using primeFaces.
My code for XHTML :
<p:column>
<!-- ... -->
<!-- inside p:cellEditor -->
<p:selectOneMenu id="selectmenu" value="#{o.rais.raison}"effect="fold" filter="true" filterMatchMode="startsWith" style="width:100%">
<f:selectItems value="#{vueRecupSurveil.raisonsBlocakge}" />
<f:selectItem ItemValue="#{vueRecupSurveil.newRaisonBlocakge}" itemLabel="Ajouter une raison"/>
<p:ajax listener="#{vueRecupSurveil.ajoutNewRaison}"/>
</p:selectOneMenu>
<!-- ... -->
</p:column>
My code for bean:
@ManagedBean(name="vueRecupSurveil")
@ViewScoped
public class VueRecupSurveil implements Serializable {
private String newRaisonBlocakge="";
private List<String> raisonsBlocakge = new ArrayList<String>();
@PostConstruct
public void init() {
// initialize list
}
public void ajoutNewRaison(AjaxBehaviorEvent event) {
if (newRaisonBlocakge.equals(((UIInput) event.getComponent()).getValue())) {
RequestContext ajax = RequestContext.getCurrentInstance();
ajax.update("addNewRaisonDialog");
ajax.execute("PF('widget_addNewRaisonDialog').show()");
}
}
}
My problem is when i click in the icon edit, in options in datatable, and change the raison, then click back in cancel icon, i can't get the initial value displayed; when i remove the ajax code for my xhtml it works.
The dialog should display the new data via ajax.