Problem: Load initial data in Xforms - Proxy Portlet

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

Problem: Load initial data in Xforms - Proxy Portlet

robinnagpal
I tried using
<xforms:insert ev:event="xforms-model-construct-done"
               nodeset="instance('user-data')"
               origin="xxforms:get-request-attribute('my-user-data')"/>

To load initial data in xfrom.  I set the 'my-user-data' in my liferay portlet.


// example  - request.setAttribute("my-user-data", myDataAsXML)
PortalUtil.getHttpServletRequest(actionRequest).setAttribute('my-user-data', dataToPrefill);

But this doens't work.  Please help
Reply | Threaded
Open this post in threaded view
|

Re: Problem: Load initial data in Xforms - Proxy Portlet

Erik Bruchez
Administrator
The reason it doesn't work is that the XForms code runs in Form Runner, which is a separate web app, possibly even in a separate servlet container.

Form Runner, and therefore any XForms code, does not share servlet requests or sessions with the proxy portlet at all.

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

Re: Problem: Load initial data in Xforms - Proxy Portlet

Stian Sigvartsen
Erik is right, the Liferay HTTP request is a completely different HTTP request to the one sent between the proxy portet and the Orbeon servlet container. It also complicates matters that Orbeon is a separate web app to your portlet.

A solution which you can consider would be to create a portlet filter which you can wrap around the proxy portlet (by registering it in its portlet.xml) to set your "my-user-data" request attribute on the proxy portlet's render request (note Render request this is different concept to HTTP request).

I can explore solutions for passing the user data from your custom portlet to the Orbeon proxy portlet (i.e. two portlets on the same Liferay page) with you if you would like to pursue this approach further.

-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].
Reply | Threaded
Open this post in threaded view
|

Re: Problem: Load initial data in Xforms - Proxy Portlet

robinnagpal
Hi Erik/Stian,

I have not deeply looked into the code of proxy portlet so far. But what I understand from you is that proxy portlet makes a new HTTP request to form runner.  The response of that will be the HTML of the form.

If this is true, I am not sure how exactly will a filter around ProxyPortlet will help, as the 'my-user-data' attribute will never be available to request received by FormRunner

Please help in populating User data/Inital data  in  Orbeon forms. Please let me know how can I make it work for a proxy portlet  
Reply | Threaded
Open this post in threaded view
|

Re: Problem: Load initial data in Xforms - Proxy Portlet

Erik Bruchez
Administrator
Robin, Stian:

I think I agree with Robin's last message. Let's summarize:

If what you want to do is to specify, within a portlet, the initial XML data Orbeon Forms should use for a given form, you CANNOT use session/request data. It just won't work, at least not without further changes to the proxy portlet. I have in mind the following.

Form Runner supports POSTing initial XML data to the /new page:

    https://github.com/orbeon/orbeon-forms/wiki/Form-Runner-~-Configuration-properties#initial-instance-posted-to-the-new-form-page

(see "Initial instance posted to the New Form page")

So you could modify the proxy portlet to do a POST of this data to Form Runner, from the portlet. And Form Runner will respond with the HTML to embed in the portlet, as usual.

So:

1. Proxy portlet obtains XML (which yes, it could obtain from the portlet request or the portlet session).
2. Proxy portlet POSTs that XML to Form Runner on the other side.
3. Form Runner response contains the form initialized with that data.

But this is currently not an existing feature, so it would need to be implemented.

-Erik