便利なユーティリティサービス

このサンプルバンドルは、AEM Forms 開発者が使用できる便利なユーティリティサービスを提供します。次のサービスを利用できます。

package aemformsutilityfunctions.core;
import java.util.Map;
import com.adobe.aemfd.docmanager.Document;
public interface AemFormsUtilities
{
public abstract com.adobe.aemfd.docmanager.Document createDDXFromMapOfDocuments(Map<String, com.adobe.aemfd.docmanager.Document> paramMap);
public abstract org.w3c.dom.Document w3cDocumentFromStrng(String xmlString);
public abstract com.adobe.aemfd.docmanager.Document orgw3cDocumentToAEMFDDocument(org.w3c.dom.Document xmlDocument);
public abstract String saveDocumentInCrx(String jcrPath,String fileExtension, Document documentToSave);

}

サンプルバンドルは、ここからダウンロードできます。

ユーティリティサービスを使用するサンプルコード

以下は、文字列から org.w3c.dom.Document を作成し、そのドキュメントを変換して CRX リポジトリに保存するために JSP ページで使用されたコードです(次のコードスニペットを参照)。

 aemformsutilityfunctions.core.AemFormsUtilities aemFormsUtilities = sling.getService(aemformsutilityfunctions.core.AemFormsUtilities.class);
com.adobe.aemfd.docmanager.Document xmlStringDoc = aemFormsUtilities.orgw3cDocumentToAEMFDDocument(aemFormsUtilities.w3cDocumentFromStrng("<data><fname>Girish</fname></data>"));
aemFormsUtilities.saveDocumentInCrx("/content/xmlfiles",".xml",xmlStringDoc);

前提条件

DevelopingWithServiceUserBundle をデプロイし、そのバンドルを起動する必要があります。

これらのユーティリティサービスを利用して CRX リポジトリにドキュメントを保存する場合は、サービスユーザーを使用した開発の記事に従ってください。fd-service ユーザーに適切な CRX フォルダーの必要な権限を必ず提供してください。

recommendation-more-help
8de24117-1378-413c-a581-01e660b7163e