I have two entities in JSF that are dropdowns. If i am selelcting month then i should compulsarily select year. If i have not selected Year and only selected month then a validation error should appear on click of submit button. Is such form of conditional validation possible in primefaces. I had tried javascript method but i failed somehow. How can it be acheived using primefaces.? Below are my two entities.
<p:outputLabel for="year" value="Year: " />
<p:selectOneMenu id="year" style="width:150px " value="#{bean.year}">
<f:selectItem itemLabel="All" itemValue="All"/>
<f:selectItem itemLabel="2014" itemValue="2014"/>
<f:selectItem itemLabel="2013" itemValue="2013"/>
<f:selectItem itemLabel="2012" itemValue="2012"/>
<f:selectItem itemLabel="2011" itemValue="2011"/>
<f:selectItem itemLabel="2010" itemValue="2010"/>
<f:selectItem itemLabel="2009" itemValue="2009"/>
</p:selectOneMenu>
<p:outputLabel for="month" value="Month: " />
<p:selectOneMenu id="month" style="width:150px" value="#{bean.month}">
<f:selectItem itemLabel="All" itemValue="All"/>
<f:selectItem itemLabel="January" itemValue="01"/>
<f:selectItem itemLabel="February" itemValue="02"/>
<f:selectItem itemLabel="March" itemValue="03"/>
<f:selectItem itemLabel="April" itemValue="04"/>
<f:selectItem itemLabel="May" itemValue="05"/>
<f:selectItem itemLabel="June" itemValue="06"/>
<f:selectItem itemLabel="July" itemValue="07"/>
<f:selectItem itemLabel="August" itemValue="08"/>
<f:selectItem itemLabel="September" itemValue="09"/>
<f:selectItem itemLabel="October" itemValue="10"/>
<f:selectItem itemLabel="November" itemValue="11"/>
<f:selectItem itemLabel="December" itemValue="12"/>
</p:selectOneMenu>