You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2020/08/28 08:22:37 UTC

[GitHub] [sling-org-apache-sling-scripting-sightly-models-provider] kwin commented on a change in pull request #1: Allow an adaptable argument

kwin commented on a change in pull request #1:
URL: https://github.com/apache/sling-org-apache-sling-scripting-sightly-models-provider/pull/1#discussion_r478933307



##########
File path: src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java
##########
@@ -124,8 +125,15 @@ public ProviderOutcome provide(final String identifier, final RenderContext rend
         // pass parameters as request attributes
         Map<String, Object> overrides = setRequestAttributes(request, arguments);
 
+        // Get adaptable from arguments
+        Object adaptableArgument = arguments.get(ADAPTABLE_KEY);
+
         try {
-            // try to instantiate class via Sling Models (first via request, then via resource)
+            // try to instantiate class via Sling Models (in order: via adaptableArgument, request, resource)
+            if (modelFactory.canCreateFromAdaptable(adaptableArgument, cls)) {

Review comment:
       Please add a null check for adaptableArgument!




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org