RationaleOften times, Orbeon Forms integrators wish to embed Orbeon Forms within a portal or another application. Orbeon Forms offers some support for this, but does not necessarily have a one-size-fits-all solution as of 2011-09-08. This page is meant to help you better understand what is involved to make such as setup work.
Existing supportOrbeon Forms features some support for portals and embedding:
What is not supported out of the box as of 2011-09-08:
ConceptsWhat embedding meansHere by "embedding" we don't mean shipping Orbeon Forms with something else. Rather we mean setting up an application to work with Orbeon Forms such as a page/form rendered by Orbeon Forms appears embedded within that application's page.
What proxying meansHere "proxying" means that Orbeon Forms runs as a separate entity, typically connected via HTTP. It could be on the same app server/container, or even in a separate machine. So for example:
NOTE: Proxying is a way to achieve embedding. It's not the only way: for example when the Orbeon Forms full portlet is used, there is no proxying going on.
URL rewritingURL rewriting means that in HTML or XML produced by Orbeon, you replace (rewrite) some URLs before sending that HTML or XML to the client.
The purpose of URL rewriting is to adjust URLs so that when the user clicks on a link or performs another client action, then links, Ajax requests, and form submission go to the "right place". The same applies to ressources loaded by the page like JavaScript, CSS, and image files.
For example, within a Java portlet container, a form submission must reach a specific portlet, not a regular web application running in the container.
Session forwardingOrbeon Form expects that if it produces a page's HTML within a given Java servlet session, then later incoming Ajax requests address the same session. This means in general that the JSESSIONID cookie received by Orbeon Forms must be correct.
This can mean, such as in the Form Runner proxy portlet or TYPO3 extension cases, that the proxy/extension must store the mapping between a client session and the Orbeon Forms session.
HTML fragmentWhen Orbeon Forms runs standalone, it produces a full HTML page. This includes HTML <html>, <head> and <body> elements. When Orbeon Forms produces HTML to be embedded into a portlet or another application, it produces an HTML fragment, rooted in a <div> element instead. This is because you can't simply embed a full HTML document within another. For any Orbeon page, you can enable the production of an HTML fragment by appending the orbeon-embeddable=true URL parameter. For example:
This produces a fragment that looks like this:
The fragment is produced by an XSLT stylesheet set via the oxf.epilogue.theme.embeddable property. By default:
When embedding Orbeon Forms, you should always set the
orbeon-embeddable=true URL parameter.What Orbeon Forms needs on the clientResourcesNOTE: Below paths starting with /orbeon denote that Orbeon Forms is installed under the /orbeon servlet context. It is not mandatory to use /orbeon.Orbeon Forms needs the following resources:
In Ajax mode, additionally:
This means that the URLs seen by the browser must, directly or via proxying, reach Orbeon Forms. The Orbeon XForms ServerThe Orbeon XForms Server responds at the path /orbeon/xforms-server. It does the following:
Any access to the XForms Server must include the proper session cookie. Communication with the server to handle a given page's updatesAfter an Orbeon Forms form is loaded in the browser, the user can interact with it. As that happens, the form typically needs to talk back to the XForms Server, via two means:
Communication via AjaxAjax requests use the URL of the XForms Server. Communication via HTML Form submissionIn Noscript mode, things are different: because no JavaScript is used, the action attribute on the HTML <form> element is used to submit the whole HTML form. Each user action translates into an HTML form submission, which reloads the page entirely from the server. For a given page, Orbeon Forms generates an action attribute with the URL of the current page as known by Orbeon. For example, if you load this standard Orbeon Forms page:
Then that's also the value placed in the <form> element:
The POST method is always used for this. NOTE: In some modes, instead, the URL is /orbeon/xforms-server-submit instead. [TODO: explain]Navigating to new pagesUsing XForms, there are 2 ways of navigating to a new page:
This translates on the client to:
Simple caseThis behaves as if the user had entered the given URL in the browser URL bar. This case is rare, and can even be disabled. HTML form POSTIn this case:
Proxy portlet scenariosWhat this isThis describes the case of a JSR-168/286 portlet with a hypothetical proxy portlet, similar to the Form Runner Liferay Proxy Portlet. Initial form load
URL rewriting for resources and Ajax requestsSay URL rewriting is NOT performed. This URL will be present in the browser:
Unless there is an /orbeon context deployed locally, requesting this URL will fail.With a JSR-286 container, resource URLs can be rewritten to portlet resource URLs, and the proxy portlet can forward the request to Orbeon. With a JSR-168 container, resources cannot go through the portlet, so either a proxy servlet must be used, or the Orbeon Forms servlet must be deployed under /orbeon. URL rewriting for HTML form posts (Noscript updates and page navigation)This is an important one. Imagine, in particular in Noscript mode, that the HTML <form> action URL is not rewritten. Its value is, for example:
When the user clicks a button, the browser submits the whole page to that URL, which belongs to Orbeon Forms. Orbeon Forms produces a response which does not include the portal's header, footer, decorations, etc. In effect, the user has left the portal. What needs to be done here is that the URL must be rewritten to be a portlet action URL. If this is done, the URL as seen in the browser is a URL encoded by the portal. When the HTML form is submitted to that URL, the portal can:
The data flow here is interesting:
Embedded proxy scenariosRationaleThis describes the scenario where the form is embedded within an application which is not a portal. TODO: to possibilities for updates:
How to rewrite URLsIn a very simple case, the HTML returned by Orbeon could simply be parsed for URLs, in particular the <form action=""> attribute. A better way, used by the Form Runner proxy portlet, is to put the Orbeon server in a special mode, where it encodes all URLs via a special WSRP-inspired scheme of markers. The portlet can then efficiently parse the resulting HTML for such markers, and rewrite URLs as it goes. [SINCE: 2012-05-14] When Orbeon Forms receives a Orbeon-Client header set to the value portlet, it does the following:
This header must be set on all requests for pages, HTML, and CSS. NOTE: Between 2011-10-18 and 2012-05-14, the header was named Orbeon-Container instead of Orbeon-Client. It was renamed for clarity. Orbeon Forms has a Java class which helps deal with WSRP encodingL WSRP2Utils.java. |
