Skip to content
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

Added request attribute annotation. #119

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

royteeuwen
Copy link
Contributor

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?

…y-use=${'com.cognifide.slice.TestModel' @ myAttribute='aValue'} to read out the attribute
@coveralls
Copy link

Coverage Status

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

@royteeuwen
Copy link
Contributor Author

Have to see to add some tests maybe

@antonyh
Copy link

antonyh commented Apr 27, 2020

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.

@royteeuwen
Copy link
Contributor Author

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

@antonyh
Copy link

antonyh commented Apr 27, 2020

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?

@royteeuwen
Copy link
Contributor Author

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

@antonyh
Copy link

antonyh commented Apr 30, 2020

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.

@mmajchrzak
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants