Sling Models: How to write Sling Model Injector
Once I needed to write several debugging servlets for some functionality. Those servlets had to accept a big pile of parameters and I was tired of having tens of rows like String paramValue = request.getParameter(“paramName”). Luckily, I’ve already known Sling Models. So I’ve decided to find the way to inject these parameters into the model, so I could write just request.adaptTo(MyModel.class) . Unfortunately, I found nothing, so decided to write it myself. So in this article, I will show you how to write custom Sling Model injector on the example of Sling Model Request Parameter Injector. ...