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>.
|
| @Inject | ||
| private ChildrenFieldProcessor childrenFieldProcessor; | ||
|
|
||
| @Inject |
There was a problem hiding this comment.
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