We may face a situation when we have to specify more than one DataModel and DataModelSelection in JBoss Seam managed [backing] bean as below.
Let us assume a multiple choice question which can also have more than one exhibits as below. [The Factory methods are omitted for simplicity]
@DataModel(scope = ScopeType.PAGE)
private List<MultipleChoiceOption> options;
@DataModelSelection
@Out(required = false)
private MultipleChoiceOption activeOption;
@DataModel(scope = ScopeType.PAGE)
private List<Exhibit> exhibits;
@DataModelSelection
@Out(required = false)
private Exhibit activeExhibit;
In the above code, we have to specify to which DataModel the DataModelSelection relates to. Else we get the below Exception. [DataModelSelection annotation need not have the attribute value when only one DataModel is present in a backing bean]
Caused by: java.lang.IllegalStateException: Missing value() for @DataModelSelection with multiple @DataModels
Below is the code which will not throw such Exception.
@DataModel(scope = ScopeType.PAGE)
private List<MultipleChoiceOption> options;
@DataModelSelection("options")
@Out(required = false)
private MultipleChoiceOption activeOption;
@DataModel(scope = ScopeType.PAGE)
private List<Exhibit> exhibits;
@DataModelSelection("exhibits")
@Out(required = false)
private Exhibit activeExhibit;
