You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Justin Edelson (JIRA)" <ji...@apache.org> on 2017/10/10 17:19:00 UTC

[jira] [Assigned] (SLING-7187) Use of Injector-specific annotation and @Optional results in required-value

     [ https://issues.apache.org/jira/browse/SLING-7187?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Justin Edelson reassigned SLING-7187:
-------------------------------------

    Assignee: Justin Edelson

> Use of Injector-specific annotation and @Optional results in required-value
> ---------------------------------------------------------------------------
>
>                 Key: SLING-7187
>                 URL: https://issues.apache.org/jira/browse/SLING-7187
>             Project: Sling
>          Issue Type: Bug
>          Components: Extensions
>    Affects Versions: Sling Models Impl 1.4.4
>            Reporter: Justin Edelson
>            Assignee: Justin Edelson
>             Fix For: Sling Models Impl 1.4.6
>
>         Attachments: SLING-7187.diff
>
>
> If there is a model class like
> {code}
>     @Model(adaptables = Resource.class)
>     public class ModelClass {
>         @ValueMapValue
>         private String otherText;
>         @Override
>         public String getOtherText() {
>             return otherText;
>         }
>         @ValueMapValue
>         @Optional
>         private String emptyText;
>         @Override
>         public String getEmptyText() {
>             return emptyText;
>         }
>     }
> {code}
> It would be a reasonable expectation that the {{emptyText}} field will be optional. But that is not actually the case since the {{@ValueMapValue}} has a default {{optional}} attribute of {{false}}.
> Can be worked around by using {{@ValueMapValue(optional = true)}} instead of having the separate {{@Optional}} annotation.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)