开发者

SelectOneMenu changes its value only after the refresh

I use a SelectOneMenu component and a SelectBooleanCheckbox component on my JSF page.

If the combo box is selected, my SelectOneMenu should be blocked and is set to the first element (reset).

Now I have value change 开发者_运维问答listener for combobox implemented and blocking of the SelectOneMenu works very well.

But, when I reset the ComboBox, the SelectOneMenu is set to the old (previous) element.

I think there is something like cache used by JSF.

How do I reset the SelectOneMenu control?

I have linked the value-attribute to the bean property. I set a value for this attribute in the value change listener.

Thanks!


I'll assume that you're using immediate="true" on the checkbox and that you're calling FacesContext#renderResponse() in your value change listener method (otherwise you would go mad with validations).

In that case, you need to set the value of the dropdown component itself to null as well.

UIInput dropdown = (UIInput) facesContext.getViewRoot().findComponent("formid:dropdownid");
dropdown.setValue(null);

An alternative to UIViewroot#findComponent() is to bind it as bean property.

<h:selectOneMenu binding="#{bean.dropdown}">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜