Apache Tomcat 8.0
JSF 2.1
I have p:selectOneMenu:
Code: Select all
<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>
widgetVar.selectValue(value);
I apply it to my case:
Code: Select all
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, but does not set value
alert(categoryListWV.getSelectedValue());//works correct
alert(categoryListWV.getSelectedLabel());//works correct
openAddCategBtn();//open dialog where p:selectOneMenu located
}
I think that is a problem.
In my opinion here categoryListWV.selectValue(parent); parent should be CategoryEntity type( now it is String).
Can it be fixed or easier will be create String list instead CategoryEntity list?