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

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

Consider situation that I would like to check whether my component model can be 
adopted in view. If not I want to display some placeholder instead of that 
component. I am afraid but this is currently not possible without getting 
warning: "Required properties ... on model class class ... were not able to be 
injected.".

In my context at the first time when I create a component model all fields are 
always null so I have to mark all of them as @Optional . I cannot change that 
mechanism, so proposed improvements are very important in my situation (and 
potentially for many other users who are using CQ/AEM).

> 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