Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Create and run a prefill service, sample boilerplate project download link is missing

Avatar

Level 1

https://helpx.adobe.com/aem-forms/6-2/prepopulate-adaptive-form-fields.html

Create and run a prefill service

The prefill service is an OSGi bundle. You create the OSGi bundle, upload, and install it to AEM Forms bundles. Before you get started with creating the bundle:

  • Download the AEM 6.2 Forms Client SDK from Adobe public repository.
  • Download the boilerplate package (Prefill-Sumbit-XMLsAndContentPackage.zip)
  • Place the data xml (prefill XML) file in the crx-repository. You can place the file at any location in the \contents folder of crx-repository .

there is no link to download boilerplate project !!!!

20 Replies

Avatar

Employee

There is a DOWNLOAD section in the article after section - Adaptive form using XFA form template. It contains link to download the boilerplate package. The name of the boilerplate package zip is Prefill-Sumbit-XMLsAndContentPackage.zip. Kindly take a look. If you still face the issue, use direct link https://helpx.adobe.com/aem-forms/6-2/prepopulate-adaptive-form-fields/_jcr_content/main-pars/downlo....

Regards,
Khushwant Singh

Thanks for your reply. However, the zip you gave here doesn't contain the boilerplate project. 

Avatar

Former Community Member

Was the boilerplate zip ever located? I found the zip file provides examples for preloading data via URL. I did not see anything related to an example of a prefill service.

 

Specifically AdaptiveFormContainer (configuration) => Prefill Service

Thanks

Joel

Avatar

Level 3

Anyone found how to do this? Kindly share the boilerplate if anyone has.

Avatar

Level 2

Sample prefill service

package com.adobe.test;

import com.adobe.forms.common.service.DataXMLOptions;

import com.adobe.forms.common.service.DataXMLProvider;

import com.adobe.forms.common.service.FormsException;

import java.io.InputStream;

import javax.jcr.Node;

import org.apache.felix.scr.annotations.Component;

import org.apache.felix.scr.annotations.Service;

import org.apache.sling.api.resource.NonExistingResource;

import org.apache.sling.api.resource.Resource;

import org.apache.sling.api.resource.ResourceResolver;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

@Component(

  immediate = true,

  metatype = true,

  label = "Default Form Prefill service"

)

@Service({DataXMLProvider.class})

public class Prefill implements DataXMLProvider {

  private Logger logger = LoggerFactory.getLogger(Prefill.class);

  public Prefill() {

  }

  public InputStream getDataXMLForDataRef(DataXMLOptions options) throws FormsException {

  if (options.getDataRef() == null | "".equals(options.getDataRef())) {

  Resource formResource = options.getFormResource();

  ResourceResolver resolver = formResource.getResourceResolver();

  InputStream result = null;

  try {

  String nodePath = "/content/prefillservice.xml";

  Resource fileResource = resolver.resolve(nodePath);

  if (fileResource instanceof NonExistingResource) {

  return null;

  } else {

  Node jcrNode = (Node)fileResource.adaptTo(Node.class);

  Node jcrContent = jcrNode.getNode("jcr:content");

  result = jcrContent.getProperty("jcr:data").getBinary().getStream();

  return result;

  }

  } catch (Exception var9) {

  this.logger.warn("unable to read data for the dataRef ");

  throw new FormsException(var9);

  }

  } else {

  return null;

  }

  }

  public String getServiceName() {

  return "myServiceName";

  }

  public String getServiceDescription() {

  return "My Service";

  }

}

Avatar

Level 3

Hi Vijay, Have tried to create a service and deploy it, but its not available for selection in Adaptive form.

Can you share the complete project with pom.xml?

Avatar

Level 2

Currently, I am unable to share the complete project. Did you included package in export path?

<plugin>

  <groupId>org.apache.felix</groupId>

  <artifactId>maven-bundle-plugin</artifactId>

  <extensions>true</extensions>

  <configuration>

  <instructions>

  <Bundle-SymbolicName>com.adobe.qe.af.af-qe-core-bundle</Bundle-SymbolicName>

  <Export-Package>

  com.adobe.test.*

  </Export-Package>

  <Import-Package>

  com.adobe.aemds.guide.progressive.* 

  </Import-Package>

  </instructions>

  </configuration>

  </plugin>

Avatar

Level 3

prabuj201987

I think I had a similar problem a few days back. In my case the bundle was getting active but the pre-fill service I created was not getting active/satisfied, due to run-time dependencies of some class (some class related to w3c dom document, if I remember correctly).

Please check if you are also facing something similar, where some run-time dependencies are missing.

Hope this helps !!!

Cheers,

Jagjeet Singh

AEM Forms Blog

Avatar

Level 3

Hi jagjeetthukral,

Sorry, could not understand fully, as i am still in learning path.

1. Where should i go and check for these runtime dependencies?

2. Could you please elaborate on how you fixed this?

Avatar

Level 3

prabuj201987​, you can go to /system/console and then to your specific bundle, and then check if your service is being exported. Also, in addition, you can go /system/console/components to check if your service is satisfied.

I can help you with next steps once you help me with the status of these things.

Cheers,
Jagjeet Singh

AEM Forms Blog

Avatar

Level 3

Hi jagjeetthukral​,

I could see my service under active status in /system/console -> bundles.

Under /system/console/components could not see my service.

Avatar

Level 3

Then, you can go to bundles, stop & start your bundle. Look into the error logs and check if there are any errors during activation.

Cheers,

Jagjeet Singh

AEM Forms Blog

Avatar

Level 3

jagjeetthukral​ Thanks i was missing aemfd-client-sdk-6.3.0.jar. Have added the dependency to pom xml and now there is no error in the log. But still i could not see my service under /system/console/components also its not visible for selection in the Adaptive form container configuration. Please advise further.

Avatar

Level 3

Hi prabuj201987​,

You will have still have some runtime error(s) I think. Please clear your error.log file, restart you bundle. And please share your logs, screenshot of your bundle details page (/system/console/bundles/bundle-number)  and components page.

Its will be able to help me debug your issue.

Cheers,

Jagjeet Singh

AEM Forms Blog

Avatar

Level 3

Hi jagjeetthukral​, Please find below requested details. I am unable to upload the complete error.log as there is no file upload option.

Please let me know if you need more details.

Screen Shot 2018-02-20 at 10.59.46 PM.pngScreen Shot 2018-02-20 at 10.58.59 PM.png

Avatar

Level 3

Hi Prabu,

I will need the complete screenshot of your bundle page and components page and error logs.

Why don't you try and add debug pointers, that will help you find exact problem easily

Cheers,

Jagjeet Singh

Avatar

Level 3

Hi jagjeetthukral

How to set the debug pointers not aware of this feature? Are you talking about the debug pointer in IDE?

Avatar

Level 3

hi jagjeetthukral​,

We have got the code from adobe support and its working fine without errors. Thanks for the help.

Avatar

Level 2

Hi,

please provide complete project.

I need to work on pre-fill service.

Avatar

Level 3

Hi Vijay. Tried your suggestion still not working. Below is my pom.xml. Please let me know if anything is missing.

Actually this is the first time i am creating a custom osgi service, if you are unable to share the code kindly point me to appropriate tutorial which would be really helpful.