[ 
https://issues.apache.org/jira/browse/ISIS-3293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17638227#comment-17638227
 ] 

Andi Huber commented on ISIS-3293:
----------------------------------

Contract for ViewModel implementations:
* there is a single public constructor
* it may have arbitrary many arguments of arbitrary type
* first String argument found is passed in the viewmodel's memento
* any other arguments are resolved via ServiceRegistry - if not found either 
pass in null or throw (to be decided)
* we don't require @Inject or @Autowired annotations on the constructor
* we could honor @Qualifier and other Spring programming model specific 
annotations on the constructor arguments - but maybe for simplicity don't 
implement that just now

Naturally this also allows for the idiom of passing in the ServiceInjector as 
an argument and do the injection point resolving (field-style) programmatically.

> ViewModel implementations need Means of using Injection Points during 
> Construction
> ----------------------------------------------------------------------------------
>
>                 Key: ISIS-3293
>                 URL: https://issues.apache.org/jira/browse/ISIS-3293
>             Project: Isis
>          Issue Type: Improvement
>          Components: Isis Applib (programming model), Isis Core
>    Affects Versions: 2.0.0-M9
>            Reporter: Andi Huber
>            Assignee: Andi Huber
>            Priority: Major
>             Fix For: 2.0.0-RC1
>
>
> Uwe Jäger:
> if you implement the ViewModel interface you have to have a constructor with 
> a single String argument so the memento can be used for example to fetch some 
> entities.
> But right now with 2.0.0-M9 this can not be done directly in the constructor 
> (fetching an entity) since services that have to be injected haven't been 
> injected when the constructor is executed.
> For now I have to have an extra action that the user can execute after the 
> ViewModel is created.
> Is this by design and is there a way to fetch some entity directly in the 
> view models constructor? There used to be a viewModelInit method which made 
> that possible if I understand correctly.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to