-
1. Re: Seam 2.0: Why does @Datamodel require a setter?
fhh Aug 27, 2007 5:15 AM (in response to fhh)bump
-
2. Re: Seam 2.0: Why does @Datamodel require a setter?
pmuir Aug 27, 2007 11:39 AM (in response to fhh)If you file a JIRA issue I can move the check for the setter to later on (you will still need a setter for the DataModel if you are using @DataModelSelection though)
-
3. Re: Seam 2.0: Why does @Datamodel require a setter?
fhh Aug 27, 2007 3:24 PM (in response to fhh)Done.
http://jira.jboss.com/jira/browse/JBSEAM-1868
IMHO a setter should not even be required when susing @DataModelSelection. The datamodel should be available from the context it was outjected to. Pre Seam 2.0 this was not required so this is a clear regression to me. On the other hand adding emty setters is not that hard...
Regards
Felix -
4. Re: Seam 2.0: Why does @Datamodel require a setter?
pmuir Aug 27, 2007 3:30 PM (in response to fhh)It's required if the DataModel has been outjected to PAGE scope (as the component is event scoped but the datamodel isn't). I'll drastically reduce the requirement for the setter by only calling when we are using PAGE scope :) (n.b. previous to this change you would have got an IAE if you fall into the small group of programs who were doing this).
-
5. Re: Seam 2.0: Why does @Datamodel require a setter?
fhh Aug 27, 2007 6:30 PM (in response to fhh)Maybe I am a bit thick here but I still don't get why a setter should be needed. If the datamodel is page scoped I would expect it to go back into page context (= Contexts.getPageContext().set("name", dataModel)) after deserialization. What sense does it make to reinject it into the action bean even if that particular action bean is not called in a second request.
I always thought that @DataModel works pretty much like @Factory: Once a datamodel is created it becomes a completly independent, fist-class component. The difference is of course that @Factory is called automatically and @DataModel is only used if the annotated bean is called.
Regards
Felix -
6. Re: Seam 2.0: Why does @Datamodel require a setter?
pmuir Aug 28, 2007 6:51 AM (in response to fhh)So that when you do:
@Name("eventLister") public class EventListerAction { @DataModel(value="eventList", scope=ScopeType.PAGE) private List<Integer> eventList; @DataModelSelection("eventList") private Integer selectedEvent; @Factory("eventList") public void initRequestList() { ... } public void selectEvent() { log.info(selectedEvent); } }
That eventList isn't null (it would be unless we did this set). This seems like a reasonable assumption to me (and anyway we can't change this behaviour now!). This is the relevant commit:
http://fisheye.jboss.com/browse/JBoss/jboss-seam/src/main/org/jboss/seam/Component.java?r=1.93#l734I always thought that @DataModel works pretty much like @Factory: Once a datamodel is created it becomes a completly independent, fist-class component. The difference is of course that @Factory is called automatically and @DataModel is only used if the annotated bean is called.
@DataModel is like @Out with additional logic to "convert" the data from one type to another (e.g. List -> DataModel). However it has an additional bit (reinjecting the value when using PAGE scope) - that which we are discussing.
I've committed a fix to CVS, let me know how it works out. -
7. Re: Seam 2.0: Why does @Datamodel require a setter?
christian.bauer Aug 28, 2007 6:53 AM (in response to fhh)@DataModel is like @Out with additional logic to "convert" the data from one type to another (e.g. List -> DataModel). However it has an additional bit (reinjecting the value when using PAGE scope) - that which we are discussing.
Add this explanation and the discussion result to the docs, please. -
8. Re: Seam 2.0: Why does @Datamodel require a setter?
fhh Aug 28, 2007 8:04 AM (in response to fhh)I think I am finally getting you. IMHO it is acceptable that the backing list would be null during the second call but than null would be outjected again and the dataModel removed from its scope after the call which is probably a bit confusing :-).
But if this is correct doesn't this problem apply to any case where the scope of the datamodel is longer than that of the action bean outjecting it? The same could happen with a stateless action bean and a conversation scoped datamodel.
Regards
Felix -
9. Re: Seam 2.0: Why does @Datamodel require a setter?
pmuir Aug 28, 2007 9:34 AM (in response to fhh)But if this is correct doesn't this problem apply to any case where the scope of the datamodel is longer than that of the action bean outjecting it? The same could happen with a stateless action bean and a conversation scoped datamodel.
No because the only scope you can specify on @DataModel is PAGE (otherwise it is UNSPECIFIED aka same as the containing component).
I will write this up for the manual. -
10. Re: Seam 2.0: Why does @Datamodel require a setter?
fhh Aug 28, 2007 9:48 AM (in response to fhh)Okay. Thanks for the comprehensive information!
Regards
Felix