Hi, I am having trouble being able to pass an XML to pre-fill a form, when using the JSP integration. I have tried different XML combinations with no result, the form always appears without pre-filling. Any idea where the error is? Greetings and thanks. JSP Code: <%@ page pageEncoding="utf-8" contentType="text/html; charset=UTF-8" import="org.orbeon.oxf.fr.embedding.servlet.API" import="java.util.HashMap" %> <!DOCTYPE HTML> <html> <body> <% //String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><form><seccio1><camp1>mola</camp1><camp2>trola</camp2></seccio1></form>"; //String xml = "<form><seccio1><grid-1><camp1>mola</camp1><camp2>trola</camp2></grid-1></seccio1></form>"; String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><form><seccio1><grid-1><camp1>mola</camp1><camp2>trola</camp2></grid-1></seccio1></form>"; request.setAttribute("dades", xml); API.embedFormJava( request, // HttpServletRequest: incoming HttpServletRequest out, // Writer: where the embedded form is written "Proves", // String: Form Runner app name "senzill2", // String: Form Runner form name "new", // String: Form Runner action name null, // String: Form Runner document id (optional) null, // String: query string (optional) null // Map<String, String>: custom HTTP headers (optional) ); %> </body> </html> XForm code: <xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:saxon="http://saxon.sf.net/" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sql="http://orbeon.org/oxf/xml/sql" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:exf="http://www.exforms.org/exf/1-0" xmlns:array="http://www.w3.org/2005/xpath-functions/array" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" fr:data-format-version="4.0.0"> <xh:head> <xh:title>Formulari senzill2 per pre-omplir per request-attribute</xh:title> <xf:model id="fr-form-model" xxf:expose-xpath-types="true" xxf:analysis.calculate="true"> <!-- Main instance --> <xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id"> <form> <seccio1> <grid-1> <camp1/> <camp2/> </grid-1> </seccio1> </form> </xf:instance> <xf:insert event="xforms-model-construct-done" ref="instance('fr-form-instance')" origin="xxf:get-request-attribute('dades')"/> <!-- Bindings --> <xf:bind id="fr-form-binds" ref="instance('fr-form-instance')"> <xf:bind id="seccio1-bind" name="seccio1" ref="seccio1"> <xf:bind id="grid-1-bind" ref="grid-1" name="grid-1"> <xf:bind id="camp1-bind" name="camp1" ref="camp1" xxf:whitespace="trim"/> <xf:bind id="camp2-bind" ref="camp2" name="camp2" xxf:whitespace="trim"/> </xf:bind> </xf:bind> </xf:bind> <!-- Metadata --> <xf:instance id="fr-form-metadata" xxf:readonly="true" xxf:exclude-result-prefixes="#all"> <metadata> <application-name>Proves</application-name> <form-name>senzill2</form-name> <title xml:lang="en">Formulari senzill2 per pre-omplir per request-attribute</title> <description xml:lang="en"/> <created-with-version>2019.2.0.201912301747 CE</created-with-version> <updated-with-version>2019.2.0.201912301747 CE</updated-with-version> <library-versions> <orbeon>1</orbeon> </library-versions> </metadata> </xf:instance> <!-- Attachments --> <xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all"> <attachments/> </xf:instance> <!-- All form resources --> <xf:instance xxf:readonly="true" id="fr-form-resources" xxf:exclude-result-prefixes="#all"> <resources> <resource xml:lang="en"> <seccio1> <label>Secció 1</label> </seccio1> <camp1> <label>Camp1</label> <hint/> </camp1> <camp2> <label>Camp2</label> <hint/> </camp2> </resource> </resources> </xf:instance> </xf:model> </xh:head> <xh:body> <fr:view> <fr:body xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors"> <fr:section id="seccio1-section" bind="seccio1-bind"> <xf:label ref="$form-resources/seccio1/label"/> <fr:grid id="grid-1-grid" bind="grid-1-bind"> <fr:c y="1" x="1" w="6"> <xf:input id="camp1-control" bind="camp1-bind"> <xf:label ref="$form-resources/camp1/label"/> <xf:hint ref="$form-resources/camp1/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> <fr:c y="1" x="7" w="6"> <xf:input id="camp2-control" bind="camp2-bind"> <xf:label ref="$form-resources/camp2/label"/> <xf:hint ref="$form-resources/camp2/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:input> </fr:c> </fr:grid> </fr:section> </fr:body> </fr:view> </xh:body> </xh:html> You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/7ebfd83e-f2b8-4e24-97a7-1ae651550745o%40googlegroups.com. |
Administrator
|
Hi Patxi,
The Java embedding API makes an HTTP request to Orbeon Forms, so the `HttpServletRequest` object Orbeon Forms receives isn't the same you have in your code; you just can't set a request attribute on it, an expect it to arrive on the other side. You can either pass values by request parameters or headers. In your case, I would use a header, which you can access from the other side with `xxf:get-request-header()`. You'll let me know if this works for you! ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1594408076715-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
In reply to this post by falba48
Yes, this works for me using saxon:parse(), whithout this don't fill data, this is correct?
-- <xf:insert event="xforms-model-construct-done" ref="instance('fr-form-instance')" origin="saxon:parse(xxf:get-request-header('dades','UTF-8'))"/> Otra pregunta es: ¿es posible poner este código en la plantilla de sección? para que secciones se puedan pre-rellenar con los datos sin intervención del usuario en el edit source del form-builder. You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/f39622df-56e3-41f4-a579-0a5b6e0ad1f3o%40googlegroups.com. |
Administrator
|
Hi Patxi,
Yes, you indeed need to call `saxon:parse()`, and you code looks correct. And you can't put this in a section template, but you might be able to put it in a custom model (see link below), where you can put your custom XForms code that gets "inserted" into the forms you'd like. https://doc.orbeon.com/form-runner/advanced/custom You'll let me know if this works for you. ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1594666269242-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
In reply to this post by falba48
Yes, it has worked. At the moment it seems more interesting to put a get-request-header() in each field of the template. In that way don't have to know the variable part of the form. Thanks You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/e59da291-f234-4993-9a83-3c3655f20b6eo%40googlegroups.com. |
In reply to this post by falba48
One more question. We have a template with a section with read-only fields that is filled by the headers. But if we hide this section, the XML it sends to the servlet does not include this section. I have a way to hide the section, but the secction comes in the result XML? You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/8bf4ae2e-8667-47dc-b4ea-7152d9fcd2cfo%40googlegroups.com. |
Administrator
|
Hi Patxi,
I imagine that you are using `send()`, in which case use the `nonrelevant = "keep"` parameter (see link below). https://doc.orbeon.com/form-runner/advanced/buttons-and-processes/actions-form-runner/actions-form-runner-send ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1595289390846-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
In reply to this post by falba48
There is a small problem with the keept. It seems that since it has no visibility, it is not executing the formula, which fills in the fields with the header, nor initial value and / or calculated value. Its sending the full XML but with the no visibility fields empty, is there any way to force them to execute the get-recuest-headers ()? You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/6ff149cc-b6b1-4741-9150-d9f2c8c246a3o%40googlegroups.com. |
Administrator
|
Hi Patxi,
Are you saying that you a hidden field calculate as `xxf:get-request-header(…)`, and that the value isn't present in the data when it is sent? If so, is it present when the data is saved, in the database? If so, can you check if making the field always visible makes a difference? ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1595376789487-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
In reply to this post by falba48
Yes, but it only happens with a hidden template section. The data not come when doing a GET to the orbeon CRUD. Explain, we have a template section with the fields filled in with the get-request-headers (). If we hide this section that comes from the template it doesn't preload them, the empty XML tags come when forcing the keept. However, if you hide a section that does not come from a template, it preloads the data. It is more if what is hidden is a field of the template if it preloads it. I am testing with the orbeon version: 2019.2.0.201912301747 CE, using the embedded eXist database built into a tomcat. Server version: Apache Tomcat/9.0.33 Server built: Mar 11 2020 09:31:38 UTC Server number: 9.0.33.0 OS Name: Windows 10 OS Version: 10.0 Architecture: amd64 JVM Version: 1.8.0_211-b12 JVM Vendor: Oracle Corporation You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/a9d1134f-5824-4603-b56a-c812a57f75f4o%40googlegroups.com. |
Administrator
|
Hi Patxi,
Got it: this is because calculations are not happening for hidden section templates. Others have stumbled upon this in the past, and I've created issue #4620 for this (see 1st link below). As a workaround, you could merge the section template into the form (see 2nd link below). You'll let me know if this works for you. https://github.com/orbeon/orbeon-forms/issues/4620 https://doc.orbeon.com/form-builder/advanced/section-templates#merging-section-templates ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1595459066270-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
In reply to this post by falba48
Hi Alessandro. Yes, this has worked. But in the future we plan to integrate HTTP services and DB access into templates, it would be interesting to be able to hide the sections and incorporate services into the template. You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/5ec2d420-6d24-441a-aa7b-b7e52c51f6abo%40googlegroups.com. |
Administrator
|
Hi Patxi,
If you don't have any "private" information in the fields of the section template, an alternative would be to keep the section template visible at the level of Form Builder, and hide it with CSS. Users will be able to see the values if they look at the DOM sent to the browser, but not change the values, if you use Calculated Value fields. Would that work for your use case? ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1595639637081-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
In reply to this post by falba48
Yes, for now it works. We do not have private data in the sections. Greetings and thanks. You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/6e5ef0f0-d104-42b2-8548-1300ad2a41c8o%40googlegroups.com. |
Administrator
|
Excellent, I'm glad CSS did the trick, and thank you for the update.
‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1596043997604-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |