Hi There ,
I'm using a custom sling model which i have annotated to be adapto from resource and singHttpServletRequest .
I have designed my model with the fields same as in my form ,
Example : My form has fields "Name", "Age," "Address"
my model also has these 3 fields all injected using "
@Inject @Named (field name from form)
"
I was assuming doing this would automatically map my request parameters to sling model if i perform request.adapto(customodel.class) .However this doesn't seem to work .
Is my understanding right in doing this ? Did i miss anything here ?
regards
Hi
[Not a Solution but a good read]
Link:- http://www.wemblog.com/2014/11/how-to-use-sling-models-in-cq56.html
//How to use Sling Models in CQ5.6
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Hi Kris,
You could use the RequestAttribute[1] annotation that has been created for your use case.
Regars,
Peter
Views
Replies
Total Likes
Hi ,
Thanks for your pointers .
Regarding RequestAttribute , am not sure if requestParameter will map to requestAttribute . Will give it a try though . will keep you posted.
Views
Replies
Total Likes
Just an update ,
So I gave a try injecting request params to my model vis RequestAttribute injection , but doesn't seem to work ..
Inject @Named(field name from form) @Source("request-attributes") .
I guess in Springs there is a class RequestDataBinding which does exactly this . I wonder if something like this also exists for sling ?
Views
Replies
Total Likes
Once you have adapted your resource to slinghttprequest in sling model
All you need to do is using below code to get properties saved in node
Here I am retrieving 'text' property
Do see this article to get more idea:
Views
Replies
Total Likes
Thanks for the reply.
But this approach is leading me to the impression that I need to manually map request Params to custom mode by get and set.
I had already used annotations to map req Params to sling model shouldn't be performing it manually again. Spring requestdatabinder does exactly this. Waiting for the same in sling
Views
Replies
Total Likes
With Sling Models, you do use annotations on each data member you map https://helpx.adobe.com/experience-manager/using/sling_models.html.
Views
Replies
Total Likes
Request-parameters are not mapped with Sling-models.
Views
Likes
Replies
Views
Likes
Replies