How can we send hint of Single-Line Text component, like xml attributes in Orbeon Form Builder to data.xml?
For example:
hint: first-name="Erik" last-name="Bruchez" email="info#orbeon.com"
<?xml version="1.0" encoding="utf-8" ?>
<form>
<contact first-name="Erik" last-name="Bruchez" email="info#orbeon.com" />
</form>
Now send button generate data.xml like :
<contact>
<first-name>Erik</first-name>
<last-name>Bruchez</last-name>
<email>info#orbeon.com</email>
<phone>6505555555</phone>
</contact>
Or maybe is there some ways to define data.xml attributes from Form Builder?
It look to me like you're trying to bind a control to an attribute (/form/contact/#first-name), instead of an element (/form/contact/first-name). You can do this if you write XForms by hand, but not if you're creating the form with Form Builder. With Form Builder, the structure of the XML used to collect the data is automatically created for you by Form Builder.
If this XML needs to go to another system that expects data in a different format, then you can, on submission, implement your own service to which the data is sent, and you can do the transformation in that service, for instance using XSLT.
Related
I need help with body of POST request. I need send XML whitch can be dynamically assemble. Not only putting values in elements.
I work with Orbeon 2021.1.2 PE. There are two cases I came across when connecting to my backend and they are quite similar:
1] There is a array in the request where its length is based on the data in the form.
When using a request template:
<SendAction>
<IDs>
<ID></ID>
</IDs>
</SendAction>
You can simply put a value using //ID and the result is this:
<SendAction>
<IDs>
<ID>AAA</ID>
</IDs>
</SendAction>
But I would need a request when the number of <ID> is N like:
<SendAction>
<IDs>
<ID>AAA</ID>
<ID>BBB</ID>
<ID>CCC</ID>
</IDs>
</SendAction>
2] The request again has a dynamically long array but I need put entire object. E.g:
<Wheapons>
<Weapon>
<LicenseNumber>123456789</LicenseNumber>
<Name>Gun A</KindOfWeapon>
<Category>0</Category>
</Weapon>
<Weapon>
<LicenseNumber>987654321</LicenseNumber>
<Name>Gun B</KindOfWeapon>
<Category>0</Category>
</Weapon>
<Wheapons>
I hope you get my point. Data in second example I have in fr:dataset() and in Repeated Grid too (it is output of diferent endpoint). I tried to insert whole blocks of XML, but Orbeon always encode the characters in xml ('<' to "& lt;" and '>' to "& gt;") and therefore the request is not processed. This behavior is basically good, because I'm trying something like XML injection. But I achieve the same bad result when using the xf:element() function. Is this problem solvable by some funcitons or I'm complete wrong? Thank you!
My understanding is that your form has a repeated grid, and that you would like to call a service POSTing XML to that service based on the values of fields inside a repeated grid. This isn't something that you can do with the Services & Actions in Form Builder; currently, those only let you send individual values to a service. So, instead, you'll need to write that logic in XForms. At a high level:
The XForms will go in a custom model (doc), i.e. a separate file on the server with your XForms logic.
In that XForms, you write an event handler, for an event of your choosing, and you will dispatch that event from a process, in your properties-local.xml, with xf:dispatch() (doc).
Your XForms custom model also declares an xf:submission, to do the actual POST, an instance, with the data to be posted, and in the event handler you populate the instance from the data in your grid, and run the submission.
I find simple and dummy solution but #avernet was right. If you want generic function for whole project you must write own custom model.
Here is my snippet:
<xf:instance id="test_service-template">
<item>
<id/>
</item>
</xf:instance>
<xf:instance id="test_service-instance">
<values>
<item>
<id>123</id>
</item>
</values>
</xf:instance>
<xf:instance id="test_service-resposne-service-instance">
<response/>
</xf:instance>
<xf:submission id="test_service-submission" resource="/fr/service/custom/orbeon/echo"
ref="instance('test_service-instance')"
method="post"
serialization="application/xml"
mediatype="application/xml"
replace="instance"
instance="test_service-resposne-service-instance"/>
<xf:action id="test_action-binding">
<xf:action event="DOMActivate" ev:observer="control-2-control" if="true()">
<xf:insert context="xxf:instance('test_service-instance')" ref="values"
origin="xxf:instance('test_service-template')"/>
<xf:setvalue ref="xxf:instance('test_service-instance')/values/item[1]/id" value="'321'"/>
<xf:send submission="test_service-submission"/>
</xf:action>
</xf:action>
If you don't use Services & Actions in Form Builder you can send your own instance as body of request (test_service-instance).
Before submission you can simple build this instance (by insert and setvalue). You can put then somewhere else in form (for example under trigger). Response of submission can have own instance too.
In my ASP.Net MVC web application I used to have dhtmlxgrid plugin v 3.5 and now updated to v4.0.
Before it was easy to generate dynamic values for the grid in separate .cshtml view and only pass the url of the method inlo loadXML like this:
myGrid.loadXML('#Url.Action("XmlValues")');
Now in the version 4.0 they replaced loadXML() with load(), which still should be able to do the same thing. But instead of parsing the data into the grid it shows an alert with an xml code generated inside the view and the table body is empty. It can't even load simple xml if it was passes through the view:
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row id="1">
<cell>1</cell>
<cell>2</cell>
</row>
</rows>
But if I copy that into an external xml file and pass path to the file into the method it works correctly.
myGrid.load("/xml.xml");
What is the problem with new load() method and how to make it work with dynamic data in ASP.Net MVC as I used to?
please make sure there are no extra chars in the generated xml. For example, a space (" ") before the xml header.
When accessing the Form Builder summary, which lists the forms I currently have access to, I see the search API is called with
<query name="application-name"
path="xh:head[1]/xf:model[#id = 'fr-form-model'][1]/xf:instance[#id = 'fr-form-metadata']/*[1]/application-name[1]"
inline-label="" type="xs:string" control="output"
search-field="true" summary-field="true" match="substring" />
How/where is the path expression built?
It is built by the Form Runner summary page, the same way for Form Builder as for other forms, looking for elements with the fr-summary class.
So the summary page can find those element, Form Builder has hidden outputs with that class.
Those outputs reference real binds in Form Builder's model.
Form Runner's summary page builds the path expression by going through the ancestors of the bind mentioned in the previous points, and building and building an expression concatenating the ref on those binds.
Using Struts2, my goal is to present a simple blog to a user using Struts2 iterators, such as:
Most Recent Topic
response 1
response 2
...
Previous Topic
response 1
response 2
...
Users generate and submit each Topic/Response using a separate form, but, once submitted, I don't want them to edit the blog.
To generate either a Topic or a Response, I provide an editor (like the stackoverflow editor I'm using now) that produces html-formatted text, including whatever styling (bold, underlines, lists, etc.) that the user chooses. The text of the Topic/Response created by the user, including the html tags, is stored in a database.
However, I cannot find a way to render the Topic/Response as html in the blog. For example, text bolded in the editor shows up as <strong>text</strong> in a struts2 s:textarea tag.
I know that the s:property tag has an 'escapeHtml' attribute that will prevent this, but the s:property tag can't layout the text properly, and it seems that only the s:property tag has this attribute.
I've tried using <input value="%{#topic.content}" /> within the iterator instead of s:textarea, but it doesn't seem to recognize the #topic iteration reference.
Is there a way to do this?
use text instated of tax area .Let me know if you still facing this issue.
Use escapeHtml="false". I just tried it myself and it works as intended.
For example, with:
<s:set var="var1"><p>some stuff</p><p>other stuff</p></s:set>
<s:property value="var1" escapeHtml="false" />
renders the paragraph tags as you would expect.
How about using <pre> with <s:property>.
About html <pre> tag:
http://www.w3schools.com/tags/tag_pre.asp
I created a form using Orbeon form builder, and i included in its form instance the content of an xml file using :
<xi:include href="oxf:/path/file.xml" xxi:omit-xml-base="true" />
When i save the form in form builder and edit it, i get a new form, and when i publish it and run it in form runner i get a blank page.
Can you tell me please what's wrong with the xi:include ?
If you want to include the whole content of an external file as the instance, use:
<xforms:instance id="main-model-instance" src="oxf:/path/file.xml"/>
Here we have the model instance xml in external file at /path/file.xml and we are using this file into our form and have named the model instance as id="main-model-instance"
If you need to add part of the instance from external file, then insert that piece dynamically during xforms-model-construct-done event, e.g.:
<xforms:action ev:event="xforms-model-construct-done">
<!-- Extracts the element some-section from file.xml and uses it as the
root element of the fr-form-instance -->
<xforms:insert context="instance('fr-form-instance')"
origin="doc('oxf:/path/file.xml')/root-element/some-section" />
</xforms:action>