You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Christophe Jelger (JIRA)" <ji...@apache.org> on 2017/01/19 10:46:26 UTC
[jira] [Commented] (SLING-6478) Add a Sling model
annotation+injector for request parameters
[ https://issues.apache.org/jira/browse/SLING-6478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15829705#comment-15829705 ]
Christophe Jelger commented on SLING-6478:
------------------------------------------
I just attached a diff to add that functionality. Note that the {{@RequestParameter}} annotation can be used to inject {{String}}, {{Integer}}, and {{Date}} fields. The injector automatically converts integers and dates. To inject a {{Date}}, the annotation must have the {{simpleDateFormat}} attribute which defines the conversion format. I added these basic converters to be able to define a Sling model that can represent a basic HTML form with text, integer, and date input fields.
Following the discussion thread http://apache-sling.73963.n3.nabble.com/Sling-Model-and-Request-Parameters-tt4065648.html#a4065663, the injector ensures that a request parameter is only injected if and only if the {{@RequestParameter}} was used. That is, the injector returns null if {{@Inject}} was used.
> Add a Sling model annotation+injector for request parameters
> ------------------------------------------------------------
>
> Key: SLING-6478
> URL: https://issues.apache.org/jira/browse/SLING-6478
> Project: Sling
> Issue Type: New Feature
> Components: Extensions
> Reporter: Christophe Jelger
> Priority: Minor
> Attachments: SLING-6478-patch.diff
>
>
> It would be handy to have a @RequestParameter annotation to inject request parameters in Sling models.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)