In this blog post I will show you how you can leverage the power of Apache Sling to decrease your development effort when you are tasked with building basic components.
What we have been doing wrong
What do you do when you are given the task to build a pretty standard component with a basic dialog to save some properties on a given node and use those properties within your HTL?
You build your dialog, your HTL and when you start working on your model, you will see that you must write some very basic Java to inject those JCR properties into the properties of your Java class. You can do this either by using annotations or in some PostConstruct method and provide the appropriate getters for them.
Now this can be a very tedious task, because if you’ve read the first blog of this series, you must:
1. define a very basic interface
2. create an implementation class for it
3. annotate the implementation class
4. write your unit tests for some basic getters (because that’s what we all do, right? #codecoverage).