Orbeon Forms: Initial data posted to the New Form page through XML POST - orbeon

For a Proof of Concept we are trying to prefill a Orbeon Form field when it loads for the user. The documentation on the Orbeon website states that such an action is possible when adding a additional POST payload to the call of the form-instance (“…/new?form-version=1”). We followed the guide on the Orbeon website (https://doc.orbeon.com/configuration/properties/form-runner/form-runner-detail-page#initial-data-posted-to-the-new-form-page), but whatever we try, the field is never prefilled in the page once loaded (or within the HTML we get back from the call in Windows Powershell.
What are we doing wrong in our example? Or is this simply not yet possible in the current version over Orbeon Forms?
In order to test the scenario we installed Orbeon on a VM-instance within our IT-landscape. Additionally we enabled the POST-methods on the forms (https://doc.orbeon.com/xml-platform/controller/authorization-of-pages-and-services#backward-compatibility).
We then made a very simple form in the Form Builder, with just one field to fill, and published the form so that is could be called through the “…/new”-url of the Form Runner.
Orbeon Form example with empty field
Orbeon Form field description/properties
To access the Form with a payload we used PowerShell. Based on the documentation we tried a number of different approaches and XML-payloads, but non resulted in the field within the Form to be filled with the included value on load.
Below you can see one of the commands/payloads we tried:
$uri="http://##URL##/orbeon/fr/Test_PowerShell/Test_Powershell_prefilled_Formfield/new?form-version=1"$xmlbody = #"<form><section-1><grid-1><control-1-Powershell><xforms-input-1>NEWNEW</xforms-input-1></control-1-Powershell></grid-1></section-1></form>"#$encodedBase64 = [System.Convert]::ToBase64String($xmlbody.ToCharArray())$body = #"<form method="post" action="/path/to/new"><input type="hidden" name="fr-form-data" value=$encodedBase64 /></form>"#
$callresponse = Invoke-WebRequest -uri $uri -Method POST -body $body
$callresponse.content
As you can see below, the response of the call itself doesn’t contain any problems… just not the expected result of the field filled with the new value.
XML POST call response
Hope someone can help and explain what we are doing wrong.
Thanks in advance!

I would suggest you do the following to check that you can get this working on a verbatim install of Orbeon Forms:
Download the latest Orbeon Forms PE.
Unzip the archive, unzip the orbeon.war into an orbeon directory, move it to your Tomcat's webapps.
Rename orbeon/WEB-INF/resources/config/properties-local.xml.template to remove the .template, edit the file, and add the 2 properties below.
<property as="xs:string" processor-name="oxf:page-flow" name="page- public-methods" value="GET HEAD POST PUT DELETE"/>
<property as="xs:string" processor-name="oxf:page-flow" name="service-public-methods" value="GET HEAD POST PUT DELETE"/>
Create a form in Form Builder, and in Edit Source paste the form.xml from this gist. Publish it.
Save the data.xml from that gist. From the command line, run: curl -X POST -H "Content-Type: application/xml" -d #data.xml http://localhost:8080/orbeon/fr/a/a/new > new.html
Open new.html in an editor, and search for "Homer". You should be able to find it as the value of an input field.
Once this is working for you with a verbatim install, you can look into what is different in your actual environment that could explain the difference you are seeing. And of course, feel free to comment here should you have any questions.

Related

Eloqua form has `<eloqua />` tags inside input values

Eloqua is generating forms:
http://codepen.io/EightArmsHQ/pen/6dce8530a881a3c5795e822ffefe508b?editors=1000
But the output html looks like this:
<input value="<eloqua type='emailfield' syntax='LastName' />" class="field-size-top-large" />
I assumed that the value attribute was something that was then going to be replaced by some Eloqua JavaScript, but when I view it on the page with JavaScript, sure enough its still there:
How can I remove these tags? Is this a bug with Eloqua?
I managed to remove these. The <eloqua /> tags are inside the value field like that because they are used on Eloqua hosted pages – so for instance if the marketing team are creating a landing or targeted page inside of Eloqua, or a page that is linked to from an Eloqua email. They only work on these Eloqua pages, not in self hosted forms.
If you are going to self host these forms (for example on your own website), here are the steps you can take to remove the tags:
Click the field
Click on the merge settings button
Select None
Note that the yellow disappears
Note that there is no longer a predefined value in the field

Trying to get form data as XML via REST API

It should be a simple thing and it probably is, but I'm not achieving to get the XML data of a draft form via the REST API described in the Orbeon docs.
I did the following changes to the properties-local-dev.xml file:
<property
as="xs:string"
processor-name="oxf:page-flow"
name="page-public-methods"
value="GET HEAD POST"/>
<property
as="xs:string"
processor-name="oxf:page-flow"
name="service-public-methods"
value="GET HEAD"/>
<property
as="xs:anyURI"
name="oxf.fr.persistence.exist.exist-uri"
value="/exist/rest/db/orbeon/fr"/>
<page public-methods="GET HEAD POST" view="view.xpl"/>
<service public-methods="GET HEAD" view="view.xpl"/>
Then I tried different URL's to call the data:
http://localhost:9090/orbeon/exist/rest/db/orbeon/fr/gsmn/hello-world/draft/f025a471b2c8452dd65267cc5886063d995757f5/data.xml
http://localhost:9090/orbeon/crud/gsmn/hello-world/draft/f025a471b2c8452dd65267cc5886063d995757f5/data.xml
http://localhost:9090/orbeon/fr/service/persistence/crud/gsmn/hello-world/draft/f025a471b2c8452dd65267cc5886063d995757f5/data.xml
Form Runner resides on :
http://localhost:9090/orbeon/fr/
Is there something obvious I'm missing?
Thanks
Noel
Assuming your app name is gsmn and your form name is hello-world, then the last URL you mentioned (copied below for clarity), should work.
http://localhost:9090/orbeon/fr/service/persistence/crud/gsmn/hello-world/draft/92aad35a44876b3bfac3b4d6f835130fbd1fe19e/data.xml
However, most likely, the issue is that you're trying this with eXist, and that, as of this writing, the autosave functionality isn't supported by Orbeon Forms on eXist; it is only supported on relational databases. For more on this, see the support matrix for different databases, and the RFE to add support for autosave on eXist.

curl to upload file on Ruby on Rails application

I'm trying to use curl to upload a file to my small Ruby on Rails application.
Here is the insert.html.haml
= form_for :my_result, :url=>{:action=> 'save'}, :html => {:multipart=>true} do |f|
= f.file_field :myfile
= submit_tag 'submit'
The "save" action will be invoked when the form is submitted.
But the RoR action to view the form is the "insert" action.
I can view the "insert" form with a browser and then submit my file with no problem.
But I need to submit the file using curl.
When I do a curl -F myfile=#localfile.txt -F commit="submit" URL/insert, I only get back the "insert" form in HTML.
It doesn't seem to invoke the actual "save" action.
Started POST "/my_results/insert" for 10.15.120.173 at 2013-01-10 10:53:22 -0800
...
Rendered my_results/insert.html.haml within layouts/application (2.9ms)
I'm new to RoR and curl. I'd appreciate any help.
Thanks!
To upload the file, you must mimic the request that happens when the form is submitted.
The form's action is defined as
:url=>{:action=> 'save'}
which transaltes to
<form action="/save" method="POST">
So you should POST to /save
Second point, Rails automatically prefixes the fields names with the name of the object that is passed to form_for.
If you look at the HTML source of /insert, the file input looks like
<input name="my_result[myfile]" type="file" />
This explains the the structure of the params hash :
{
"my_result" => {
"my_file" => [the file]
}
}
which allows to access the form fields values under params[:my_result]
In summary : POST to /save and name the field my_result[my_file] :
curl -F my_result[my_file]=#localfile.txt URL/save
I'm just taking a guess here, but your POST probably isn't making it through due to Rails requiring a csrf authenticity token, which isn't being sent with your curl request.
In the console where you see the result of your POST there is probably a line that says something along the lines of WARNING: Cannot verify authenticity token.
When you create a form using a Rails helper such as form_for, Rails automatically creates a hidden field with a generated csrf token for its value. That way, when the form submits, if the token coming in with the form and the token that Rails is expecting don't match, the request will fail.
You can read up on how to use curl with Rails here.
Here is a link to the Wikipedia article on Cross Site Request Forgery.
Also, please let me know if this is at all relevant to your issue. I'm just assuming that's the cause since I've tried POSTing with curl before and had the same problem

Rendering html using Struts2

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

How do I echo a GET variable inside Rails?

I've created an iFrame component for people to integrate into their websites. The iFrame needs to be passed a GET variable from the URL string when the page is loaded on the remote site. In this case, the parent page would be called as http://www.theirsite.com/tracking=12345 and the tracking variable should be written into the html code on the remote page for the iframe when the page is rendered.
I've created versions of the code for each major language except rails. The PHP version of the code is shown below.
As a complete Rails neophyte, I'm hoping someone can generate a similar code snippet for Rails with XSS protection similar to htmlentities().
I publish the code for people to grab and copy into their sites.
... src="mysite.com?tracking=<?php echo htmlentities($_GET['tracking']); ?>" ...
The params hash contains a collection of all GET and POST variables:
... src="mysite.com?tracking=<%= CGI::escape(params[:tracking]) %>" ...
The CGI:escape() function encodes the parameter for a URL and may help prevent XSS attacks.
If you need specifically get variable you can do like this :
... src="mysite.com?tracking=<%= request.GET["tracking"] %>"

Resources