Im am using bean validation with JSF2.0. I have a validation group which I specify depending on a few conditions and link to a attribute in the managed bean. The attribute is assigned when the page first loads and works correctly (i.e. when the form is submitted the correct groups are validated). However if I change this property the validation groups are not updated and whatever the original value was set to will be used.
for example: JSF fragment:
<h:selectOneMenu id="unitOfMerchandise" value="#itemManager[targetBean].unitOfMerchandise}">
<f:selectItem itemLabel="-- select --" itemValue="" />
<f:selectItems value="#{itemManager.unitsOfMerchandise}" />
<f:validateBean validationGroups="#{itemManager.validatorClass}" />
</h:selectOneMenu>
Method:
@ManagedBean
@ViewScoped
public class ItemManager implements Serializable {
private String validatorClass = "com.rcs.itemmngr.model.validation.RegularItem"
private OpenItemRequest openItemRequest
private void onItemTypeSelected() {
validatorClass = itemManagerModel.getValidatorItemRequestClass(openItemRequest).getName();
}
///getters setters
}
Any ideas on how to get this to work? I have also looked for a way to change the validation groups programmatically in the managed bean but with no joy.