Specify multiple DataModel and DataModelSelection in JBoss Seam


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;

 
 
 
 
Comments:

Post a Comment:
  • HTML Syntax: Allowed
 

« January 2009
SunMonTueWedThuFriSat
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
       
Today

Valid XHTML or CSS?

[This is a Roller site]
 
© Karthik