Writing Macros

Writing your Macro

マクロを書く時には、次のメソッドをoverrideする必要があります。
Method Should return
hasBody() マクロがbodyを持つ場合はtrue、そうでない場合はfalse。
getBodyRenderMode() The RenderMode under which the body should be processed before being passed into the macro
isInline() マクロがblock要素(パラグラフ、テーブル、divなど)を作成する場合はfalse、it is Inlineでパラグラフを囲むことに組み入れられるべき場合にtrue。
execute() 与えられたマクロコンテンツのHTML片

Understand RenderMode

RenderModeは1片のテキストにどのwiki変換規則を適用しなければならないかを、Confluenceのwiki rendererに伝えます。
~略~

How to determine the context your macro is being rendered in

One of the parameters to the execute() method, the one with type RenderContext, can be used to determine how the macro is being rendered. See the relevant Confluence Developer FAQ entry for the details.

Accessing the Rest of the System

Like all Confluence plugin modules, Macros are autowired by the Spring framework. To obtain a manager object through which you can interact with Confluence itself, all you need to do is provide a Javabeans-style setter method for that component on your Macro class. See Accessing Confluence Components from Plugin Modules

Advanced Macro Techniques

Macros are often most powerful when combined with other plugin modules. For example, the {livesearch} macro uses an XWork plugin module to perform its server-side duties, and the {userlister} plugin uses a listener plugin module to listen for login events and determine who is online. You may also consider using a component plugin module to share common code or state between macros.

How Macros are Processed

タグ:

+ タグ編集
  • タグ:
最終更新:2012年07月31日 16:50