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

Krystian Panek commented on SLING-3679:
---------------------------------------

OK, so maybe in other words...

My idea is to implement custom strategy of injecting (or even more) that tries 
to inject all annotated field as if all of them were optional (so in 
consequence model variable from taglib <sling:adaptTo adaptable="${resource}" 
adaptTo="..." var="model"/> never be a null - what I care most). Yes I 
understand that it is currently possible if I annotate all fields with 
@Optional, but I think that there could be a better way to do this :)

> Required fields validation
> --------------------------
>
>                 Key: SLING-3679
>                 URL: https://issues.apache.org/jira/browse/SLING-3679
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions
>    Affects Versions: Sling Models Implementation 1.0.4
>            Reporter: Krystian Panek
>              Labels: models
>
> Currently if some field cannot be injected (and it is not annotated with 
> @Optional), model adapter factory returns null. However fact that some field 
> has null and all other are properly injected is acceptable in my context.
> Proposal:
> * model adapter factory does not return null if not all required fields are 
> injected,
> * result of requirement validation is serviced as for example:
> ** injecting it to some extra annotated field: @Valid boolean valid; (with 
> default false),
> ** passing bool parameter in @PostConstruct callback, for example 'valid' 
> (true if all required field are injected, false otherwise),
> * behave current behavior, new available only with extra model class 
> annotation, for example @NotNull .



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to