Slice icon indicating copy to clipboard operation
Slice copied to clipboard

Added request attribute annotation.

Open royteeuwen opened this issue 7 years ago • 8 comments

Hey guys!

I saw following request on the slice-users list, and decided to implement it: http://slice-users.2340343.n4.nabble.com/Pass-Parameters-from-Sightly-to-Slice-td66.html

I have added a new annotation, @RequestAttribute, where you can inject a request attribute into a slice resource. This can then be used in the following way:

data-sly-use=${'com.cognifide.slice.TestModel' @ myAttribute='aValue'}

@SliceResource
public class TestModel {

    @RequestAttribute
    private String myAttribute;

    public String getMyAttribute() {
        return myAttribute;
    }

}

What do you guys think?

royteeuwen avatar Oct 13 '17 19:10 royteeuwen

Coverage Status

Coverage decreased (-1.0%) to 65.98% when pulling d9b165d70ccb213100f752a7dbf4b76c61ed27a4 on royteeuwen:feature/injectable-request-attribute into 382453cdaee33417a7cdf2a0eaee13ea6b2091fa on Cognifide:master.

coveralls avatar Oct 13 '17 19:10 coveralls

Have to see to add some tests maybe

royteeuwen avatar Oct 13 '17 19:10 royteeuwen

Did this change make it into the codebase via another means, or is it still waiting merge? I tried to use this approach today (albeit with the Sling RequestAttibute annotation) on a project using Slice 4.3.2 but without joy. If it's in a newer version I can try updating to use it.

antonyh avatar Apr 27 '20 17:04 antonyh

Never found the time to fix the remarks to be honest, so it isnt in the main branch no. You are welcome to fix the remarks and get it merged, its as good as finished

royteeuwen avatar Apr 27 '20 17:04 royteeuwen

Hey @royteeuwen thanks for the speedy reply. This is tempting, I might give it a go.

But...

Logo update aside, this looks dead. It's not seen an update for three years now. @mmajchrzak is this project still alive, or is it now hosted and updated elsewhere?

antonyh avatar Apr 27 '20 18:04 antonyh

Hey @antonyh, we definitly still use this project and even updated to aem 6.5 with java 11. There is a slice 4.5 release that supports this, but the docs havent been updated.

I also find Slice pretty feature-complete, we dont need an entire new Spring, thats what the other bundles from AEM are for.

But on the other hand is Sling Models probably the way to go if you would start from scratch for a new project, because it is OOTB included

royteeuwen avatar Apr 27 '20 19:04 royteeuwen

Quite agree, Sling Models is superior, but legacy code needs to be maintained and enhanced. As an aside, I found a way to achieve my objective without needing to use @RequestAttribute this time.

antonyh avatar Apr 30 '20 11:04 antonyh

Hi @antonyh. This project has been put into "maintenance mode". We support it (and as @royteeuwen said there was even a release to make it java 11 compatible) but we've stopped actively add new things. The top reason for this is that it's hard to compete with SlingModels as it comes OOTB and does most of what Slice can do. Imo SlingModels still lacks decent dependency injection but its custom one is good enough for simple models and simple business logic. And to be fair, a need for robust DI in AEM is diminished every year as things are moved outside of AEM into middle layers or front.

mmajchrzak avatar May 04 '20 06:05 mmajchrzak