Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Sling Scripts cannot be called directly in CQ5.

Avatar

Level 9

Hi All,

I read the below :

Within Sling, scripts cannot be called directly as this would break the strict concept of a REST server; you would mix resources and representations.

If you call the representation (the script) directly you hide the resource inside your script, so the framework (Sling) no longer knows about it. Thus you lose certain features:

automatic handling of http methods other than GET, including:
POST, PUT, DELETE which are handled with a sling default implementation
the POST.jsp script in your sling:resourceType location
your code architecture is no longer as clean nor as clearly structured as it should be; of prime importance for large-scale development

I could not understand much on this. Any detailed explanation on this will be helpful.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

basically it's all about resources. You request a resource and internally sling uses a specific algorithm to determine the script which is used to render the resource in the format you request. Therefor you do not call a script and give the resource to render as paramter to it.
For details please see the Sling documentation to the script resolution algorithm [1]. With [2] there is another document available, which might be more readable.

Does this answer your question?

kind regards,
Jörg

 

[1] https://sling.apache.org/documentation/the-sling-engine/url-to-script-resolution.html
[2] http://dev.day.com/content/ddc/blog/2010/08/understanding_howsc.html

View solution in original post

0 Replies

Avatar

Level 10

 WHen a request occurs - sling decides which script (under a node) to call based on coniditons. 

Watch this playback for more information on how sling determines which script to call: 

May session of AEM Ask the Community Experts

Avatar

Correct answer by
Employee Advisor

Hi,

basically it's all about resources. You request a resource and internally sling uses a specific algorithm to determine the script which is used to render the resource in the format you request. Therefor you do not call a script and give the resource to render as paramter to it.
For details please see the Sling documentation to the script resolution algorithm [1]. With [2] there is another document available, which might be more readable.

Does this answer your question?

kind regards,
Jörg

 

[1] https://sling.apache.org/documentation/the-sling-engine/url-to-script-resolution.html
[2] http://dev.day.com/content/ddc/blog/2010/08/understanding_howsc.html

Avatar

Level 9

Hi,

I did go through the webinar, however could not relate it to the doubt mentioned above.