Expand my Community achievements bar.

SOLVED

Prefill Service in Adaptive Form

Avatar

Community Advisor

I am trying to implement the prefill services as per the documentation present in https://lhotsetechnologies.com/blog/prefill-service-in-adaptive-forms/

 

shaileshbassi_0-1656001221678.png

 

But I am not getting the values prefilled when I am previewing the same

shaileshbassi_1-1656001221645.png

 

 

I have check that the name in the java class and the field are the same as mentioned in the document.

Please help with the pointers, which might have been missed for the implementation.

Thanks 

1 Accepted Solution

Avatar

Correct answer by
Level 5

I believe you will need to manually bind (if not already done) each field to /data/name and /data/title respectively.

 

Also, looked at the code in that link you provided, can you add the following 2 lines

           rootElement.appendChild(name);
           rootElement.appendChild(title);

just before  ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

 

Cheers Moris

View solution in original post

5 Replies

Avatar

Employee Advisor

@ShaileshBassi The form tries to search for the element in the xml  with name maping and then binds the value to the field. You should check the structure of the xml being returned by the component.

Try to use this option and see if the data is merged fine in the form.

 

Mayank_Gandhi_0-1656004938358.png

 

Avatar

Community Advisor

@Mayank_Gandhi Yes, if I use this option, it works perfectly fine.

But I want to use the option to get it pre-filled from backend i.e. either by 

  • public class MyPrefillAdaptiveForm implements DataProvider (which is not working for me), or
  • public class MyPrefillAdaptiveForm implements DataXMLProvider (this one is working), as I am having the binding of the schema with the XSD file that I mentioned while creating the form.

So, want to know when we use the service to prefill the form via backend using by implementing DataProvider, is there any binding that needs to be done. If yes, how to configure that binding.

Thanks 

Avatar

Employee Advisor

@ShaileshBassi if you have binding then the data will adhere to the binding and it will be under afbounddata else just the object name 

Avatar

Correct answer by
Level 5

I believe you will need to manually bind (if not already done) each field to /data/name and /data/title respectively.

 

Also, looked at the code in that link you provided, can you add the following 2 lines

           rootElement.appendChild(name);
           rootElement.appendChild(title);

just before  ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

 

Cheers Moris