有用的公用程式服務
此範例套件提供有用的公用程式服務,可供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);
}
範例組合可從這裡🔗下載
使用公用程式服務的程式碼範例
以下是在JSP頁面中用來從字串建立org.w3c.dom.Document並轉換檔案並將其儲存在CRX存放庫中的程式碼,如下列程式碼片段所示。
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存放庫中,請依照使用服務使用者開發文章中的說明進行。 請確定您在適當的CRX資料夾上為fd服務使用者提供必要的許可權。
recommendation-more-help
8de24117-1378-413c-a581-01e660b7163e