Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

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

kevinw83897078
Level 1
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
Khushwant_Singh
Level 4
Level 4

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

kevinw83897078
Level 1
Level 1

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

joell91868939
Level 3
Level 3

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

prabuj201987
Level 3
Level 3

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

user2062153
Level 2
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";

  }

}

prabuj201987
Level 3
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?

user2062153
Level 2
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>

jagjeetthukral
Level 3
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

prabuj201987
Level 3
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?

jagjeetthukral
Level 3
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

prabuj201987
Level 3
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.

jagjeetthukral
Level 3
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

prabuj201987
Level 3
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.

jagjeetthukral
Level 3
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

prabuj201987
Level 3
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

jagjeetthukral
Level 3
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

prabuj201987
Level 3
Level 3

Hi jagjeetthukral

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

prabuj201987
Level 3
Level 3

hi jagjeetthukral​,

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

Yugandhararao_T
Level 2
Level 2

Hi,

please provide complete project.

I need to work on pre-fill service.

prabuj201987
Level 3
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.