-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/injectable request params #120
base: master
Are you sure you want to change the base?
Feature/injectable request params #120
Conversation
…y-use=${'com.cognifide.slice.TestModel' @ myAttribute='aValue'} to read out the attribute
…ys available, in contrast of sling servlet request)
… from a request immediatly instead of using request.getResource(). This way you could adapt your request in a servlet to a model with request parameters as fields.
6ba0416
to
cab9f7a
Compare
This a very nice feature! I'll review the code shortly, but having a quick glance it looks good too. Meanwhile, could you please create corresponding tickets in jira? This would be helpful. Cheers |
Done ;)
… On 17 Oct 2017, at 15:26, Maciej Majchrzak ***@***.***> wrote:
This a very nice feature! I'll review the code shortly, but having a quick glance it looks good too. Meanwhile, could you please create corresponding tickets in jira? This would be helpful. Cheers
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#120 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AEvNTmyYocFlOJQa3naa-r4Ixir4uCQKks5stKr4gaJpZM4P47ry>.
|
@@ -66,6 +60,12 @@ | |||
private ChildrenFieldProcessor childrenFieldProcessor; | |||
|
|||
@Inject | |||
private RequestAttributeProcessor requestAttributeProcessor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this is a good place for this kind of logic. Conceptually, your class needs to be annotated with @SliceResource
only if you want to map its fields from Sling resource. I can imagine a scenario when you don't need mapping to happen but still want to have request parameters/attributes injected. The mapper should not mix these things and fieldProcessors should rely on resource.
If not mapper, then what? I'd probably made RequestAttributeProcessor (and the other one) as Guice providers rather than FieldProcessor. This would make the design cleaner. The disadvantage would be that you'd need to use @Inject
annotation whenever you want the values to be injected and probably specify the name of an attribute (I'm not sure if Guice will give you information about the field name - probably no):
@Inject
@RequestAttribute("attribute")
private Boolean attribute;
Could you try with this approach?
Hey guys,
I have build this PR onto #119 , so please review that one first.
What I did in this one is go further on the request annotations, I have also added a RequestParameter annotation, where you can inject your request parameters in your slice model. Secondly I have also made it possible to actually adapt a request itself to the slice resource, where you could then achieve the following result(s):
Mapping to a servlet
Mapping to a resource type