Send orbeon form data to portlet (action request )

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Send orbeon form data to portlet (action request )

Rahul
As of now I am sending form data to one servlet (http request). But now I need to send form data to life ray portlet. In liferay portlet I need to retrieve the form data from the request (action request) and based on the logged user details I will perform the business logic.

How do I send form data to portlet and retrieve the form data in the portlet?  Any suggestions or guidelines to achieve the requirement?
Reply | Threaded
Open this post in threaded view
|

Re: Send orbeon form data to portlet (action request )

Erik Bruchez
Administrator
Rahul,

It might be that Liferay has some ways of doing it, but I am not aware that you can send data to a portlet directly from a completely external source. All portlet URLs, such as action and resource URLs, are encoded by the portal, and from an external service you usually cannot directly reach a portlet.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Send orbeon form data to portlet (action request )

Stian Sigvartsen
Hi Rahul

If you want to use a Liferay action URL for a XForms submission then one approach would be to stick a portlet filter around the Orbeon proxy portlet to intercept Render requests for Orbeon froms. Then you can use Liferay's PortalUtil class to create the necessary actionURL. For example:

void doFilter(RenderRequest request, RenderResponse response, FilterChain chain) throws java.io.IOException, PortletException {

  LiferayPortletResponse rr = PortalUtil.getLiferayPortletResponse(renderResponse);
  LiferayPortletURL actionURL = rr.createActionURL("theotherportletid_WAR_name") ;

  request.setAttribute("actionURL", actioURL.toString());
}

You would need to declare this filter in your portlet.xml as well.

Then on the Orbeon xform definition you can retrieve the value of the request attribute using the following Orbeon Forms proprietary XPath function. http://wiki.orbeon.com/forms/doc/developer-guide/xforms-xpath-functions#TOC-xxf:get-request-attribute-

The following snippet of XForms markup should place the action URL into the root element of an XForms instance called "my-instance" (change accordingly).

<xf:action ev:event="xforms-ready">
  <xf:insert ref="instance('my-instance')" origin="xxf:get-request-attribute('actionURL')"/>
</xf:action>

From this point you can use the URL for any XForms submission used as part of the user's form session. If you want to use it for when you process the final form submission, then you may need to set the URL into the default (first) XForms instance within your form, which will get sent to your processing URL (standard Orbeon behaviour).

Please note: This doesn't get around the issue of you needing Liferay to recognise the logged in user, because Orbeon forms doesn't contain any reference to the authenticated session in Liferay.

So there you have some ingredients for a solution, it may require a bit a bit of tweaking. I'm happy to assist.

Alternatively, there's an approach which simplifies everything which is using my Social Apps Proxy app available on the Liferay Marketplace. It will take care of linking your authenticated Liferay user session with Orbeon Forms, so you can call Liferay webservices on behalf of the authenticated user. All it requires on the Orbeon Forms side is -

1) Configure Orbeon with it as its HTTP proxy server
2) Set a couple of HTTP headers when you're making your XForms submissions
3) The Orbeon form needs to be presented via Liferay portal. For example using the standard Orbeon proxy portlet.

Just let me know if you would like me to elaborate on this.

-Stian

--
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 post to this group, send email to [hidden email].