3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CQ5 Tag Library

Last updated at Posted at 2013-06-25

テンプレート開発を行うにあたって、共通で利用できるライブラリーのメモ

global.jsp
puts <%@include file="/libs/foundation/global.jsp"%>

この共通ライブラリを読み込むためのおまじないを必ずしましょう。便利です。
global.jspの中身は以下になります。

global.jsp
puts 
<%@page session="false" import="javax.jcr.*,
        org.apache.sling.api.resource.Resource,
        org.apache.sling.api.resource.ValueMap,
        com.day.cq.commons.inherit.InheritanceValueMap,
        com.day.cq.wcm.commons.WCMUtils,
        com.day.cq.wcm.api.Page,
        com.day.cq.wcm.api.NameConstants,
        com.day.cq.wcm.api.PageManager,
        com.day.cq.wcm.api.designer.Designer,
        com.day.cq.wcm.api.designer.Design,
        com.day.cq.wcm.api.designer.Style,
        com.day.cq.wcm.api.components.ComponentContext,
        com.day.cq.wcm.api.components.EditContext"
%><%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><%
%><%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %><%
%><%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%
%><%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %><%
%><%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %><%
%><cq:defineObjects />

常に使うclassファイルのインポートとタグの宣言ができており、 特に最後に記載されている
**<cq:defineObjects />**タグで、jspのプログラムが簡略化できるようになっています。

使えるタグとしては、以下のものをよく使ってます。

  • currentPage
  • properties
  • currentDesign
  • currentStyle

応用編としては以下を覚えます。

  • resource
  • currentNode
  • log

次回は上記タグの使い方など。

3
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?