I am having trouble getting the Omnifaces skipValidators tag to work with Primefaces ajax events. Basically, I need to update many elements in a form based on the selection of a selectOneMenu, but I also need to retain any values already entered and not validate the form. However, I can't get it to work. Here's a small demonstration of the problem:
The xhtml:
<h:form>
<h:panelGrid columns="3">
<p:outputLabel for="console" value="Basic:" />
<p:selectOneMenu id="console" value="#{testBean.value}" style="width:125px">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem itemLabel="Xbox One" itemValue="Xbox One" />
<f:selectItem itemLabel="PS4" itemValue="PS4" />
<f:selectItem itemLabel="Wii U" itemValue="Wii U" />
<p:ajax event="change" process="@form" update="@form">
<o:skipValidators/>
</p:ajax>
</p:selectOneMenu>
<p:message for="console"/>
<p:outputLabel for="reqField" value="RequiredField:"/>
<p:inputText id="reqField" required="#{testBean.required}" requiredMessage="REQUIRED!"/>
<p:message for="reqField"/>
</h:panelGrid>
</h:form>
The testBean:
@Named(value = "testBean")
@SessionScoped
public class TestBean implements Serializable {
private String value;
/**
* Creates a new instance of TestBean
*/
public TestBean() {
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public boolean isRequired() {
return this.value != null && !this.value.isEmpty();
}
}
When the page loads, it looks correct - there is no asterisk by reqField
. Upon selecting one of the console values, the page changes correctly, and an asterisk appears next to the reqField
. However, after a console values is selected, if 'Select One' is chosen again from the menu, a validation error is shown.
If I understand correctly, o:skipValidators
should prevent the validation from happening. What's going on here?
I'm using omnifaces 2.3 and primefaces 5.1.12