何も指定しなくても、global.jsp
をインクルードすると、通常 JSP で使用可能なすべてのオブジェクトへのアクセスが HTL で提供されます。これらのオブジェクトは、Use-API を利用した際に一緒に提供されます。
これらのオブジェクトを使用すると、よく使用する情報に便利にアクセスできます。それらのオブジェクトのコンテンツには、ドット表記を使用してアクセスできます。また、data-sly-list
または data-sly-repeat
を使用すると、反復処理が可能です。
変数名 | 説明 |
---|---|
properties |
現在の Resource のプロパティのリスト。org.apache.sling.api.resource.ValueMapに支援 |
pageProperties |
現在の Page のページプロパティのリスト。org.apache.sling.api.resource.ValueMapに支援 |
inheritedPageProperties |
現在の Page の継承されたページプロパティのリスト。org.apache.sling.api.resource.ValueMapに支援 |
次に示す各オブジェクトは、対応する Java オブジェクトをベースとします。
以下の表では、特に便利な変数を太字で強調表示しています。
変数名 | 説明 |
---|---|
component |
com.day.cq.wcm.api.components.Component |
componentContext |
com.day.cq.wcm.api.components.ComponentContext |
currentDesign |
com.day.cq.wcm.api.designer.Design |
currentNode |
javax.jcr.Node |
currentPage |
com.day.cq.wcm.api.Page |
currentSession |
javax.servlet.http.HttpSession |
currentStyle |
com.day.cq.wcm.api.designer.Style |
designer |
com.day.cq.wcm.api.designer.Designer |
editContext |
com.day.cq.wcm.api.components.EditContext |
log |
org.slf4j.Logger |
out |
java.io.PrintWriter |
pageManager |
com.day.cq.wcm.api.PageManager |
reader |
java.io.BufferedReader |
request |
org.apache.sling.api.SlingHttpServletRequest |
resolver |
org.apache.sling.api.resource.ResourceResolver |
resource |
org.apache.sling.api.resource.Resource |
resourceDesign |
com.day.cq.wcm.api.designer.Design |
resourcePage |
com.day.cq.wcm.api.Page |
response |
org.apache.sling.api.SlingHttpServletResponse |
sling |
org.apache.sling.api.scripting.SlingScriptHelper |
slyWcmHelper |
com.adobe.cq.sightly.WCMScriptHelper |
wcmmode |
com.adobe.cq.sightly.SightlyWCMMode |
xssAPI |
com.adobe.granite.xss.XSSAPI |
JavaScriptを使用してHTLロジックをバックアップできます。 ただし、推奨または推奨される方法は、Slingモデルを使用することです。