Dynamic datasource support in orbeon .. Help !!

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

Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
I read the article about dynamic datasource support in orbeon @

http://wiki.orbeon.com/forms/doc/developer-guide/form-runner/mysql-persistence-layer#TOC-Dynamic-datasource


Here is my constraint. I have a sample web application where from my spring controller i will redirect to a JSP page named redirection.jsp (where i get the orbeon form URL) which inturn redirects to orbeon form. Sample code included in redirection.jsp is as follows


        orbeonUrl = (String) request.getAttribute("orbeonUrl"); // where i get the orbeon form URL
        response.setHeader("test", " agent"); // set a sample header names test and its value
        response.sendRedirect(orbeonUrl); // redirect to orbeon page


But i tried to get the test header value in the orbeon form but its null. Infact even when i redirect to a jsp page from redirection.jsp(instead of orbeon form) and try to get the value of the header, it is returning null. How can i set and get the orbeon-datasource header which is necessary for the dynamic datasource in orbeon. .. Please help !!
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic datasource support in orbeon .. Help !!

Erik Bruchez
Administrator
Karthik,

I think this is an issue with the way you use the Servlet API.

response.sendRedirect() sends a redirect status code to the client
(web browser). This response will also have the header you previously
set with setHeader().

The browser then issues a new HTTP GET request to the server. That
request will not have the header you set, because, well, the browser
has no reason do send it back to the server. So Orbeon won't receive
that header.

What you might want instead is using a Servlet forward, with
RequestDispatcher.forward(). I warn you that this is often a bit
tricky due to the way the Servlet API is designed, but it's doable (we
use this in Orbeon Forms internally as well).

-Erik

On Wed, Jun 9, 2010 at 12:44 AM, karthik Jayaraman <[hidden email]> wrote:

>
> I read the article about dynamic datasource support in orbeon @
>
> http://wiki.orbeon.com/forms/doc/developer-guide/form-runner/mysql-persistence-layer#TOC-Dynamic-datasource
>
>
> Here is my constraint. I have a sample web application where from my spring
> controller i will redirect to a JSP page named redirection.jsp (where i get
> the orbeon form URL) which inturn redirects to orbeon form. Sample code
> included in redirection.jsp is as follows
>
>
>        orbeonUrl = (String) request.getAttribute("orbeonUrl"); // where i get the
> orbeon form URL
>        response.setHeader("test", " agent"); // set a sample header names test and
> its value
>        response.sendRedirect(orbeonUrl); // redirect to orbeon page
>
>
> But i tried to get the test header value in the orbeon form but its null.
> Infact even when i redirect to a jsp page from redirection.jsp(instead of
> orbeon form) and try to get the value of the header, it is returning null.
> How can i set and get the orbeon-datasource header which is necessary for
> the dynamic datasource in orbeon. .. Please help !!
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Dynamic-datasource-support-in-orbeon-Help-tp2248429p2248429.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
But request dispatcher is used to forward the request within the application. I cant use request dispatcher across the application.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Dynamic datasource support in orbeon .. Help !!

Erik Bruchez
Administrator
Not quite true: all app servers have settings to allow for
cross-servlet context forwards and includes. With Tomcat, for example,
this is done on the Context element with crossContext="true":

http://wiki.orbeon.com/forms/doc/developer-guide/xforms-with-java-applications

-Erik

On Sun, Jun 13, 2010 at 6:56 AM, karthik Jayaraman <[hidden email]> wrote:

>
> But request dispatcher is used to forward the request within the application.
> I cant use request dispatcher across the application.
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Dynamic-datasource-support-in-orbeon-Help-tp2248429p2253456.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
Yep its true. Here is my senario.

     I have my application running in jboss. In that application i have a link. Upon clicking that link users will be navigated to a orbeon form.

 What i am trying to do is, set the datasource header in the request that is forwarded to orbeon thus i can use dynamic datasource support in orbeon. But is it really necessary for me to follow the procedure described in this link ?

http://wiki.orbeon.com/forms/doc/developer-guide/xforms-with-java-applications 

I can set the following in my application

         ServletContext ctx2 = application.getContext("/orbeon");
         RequestDispatcher rd = ctx2.getRequestDispatcher("************some form url*********");
         response.setHeader("Orbeon-Datasource","datasource1");
         rd.forward(request, response);

So when the form mentioned in the **********some form url********** is loaded, orbeon can identify the datasource name from the header value and fetch the data accordingly. How can i achieve this is JBOSS ?






Reply | Threaded
Open this post in threaded view
|

Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
Awaiting for reply !!
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

Gaurav Shah
Hi Karthik,
I am not an Orbeon expert and I have also recently started using Orbeon. I do have some good java/j2ee knowledge though :)
I am not 100% sure if my suggestion would work, but here is what I suggest you to try. 
1. Create a subclass of HttpServletRequestWrapper and wrap the request.
2. Your wrapper woud get you the ability to add the HTTP header. You will probably override httpHeader related methods (getHeader, getHeaderNames,getHeaders etc)
3. then call the rd.forward with new wrapped request.
 
 
  ServletContext ctx2 = application.getContext("/orbeon");
        RequestDispatcher rd = ctx2.getRequestDispatcher("************some
form url*********");
        newRequestObj=new RequestWrapperClass(request);
        rd.forward(newRequestObj, response);
 
Let us all know if this worked for you or not.
Thanks.

 
On Tue, Jun 22, 2010 at 1:00 PM, karthik Jayaraman <[hidden email]> wrote:

Awaiting for reply !!
--
View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Dynamic-datasource-support-in-orbeon-Help-tp2248429p2264534.html
Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
Gaurav Shah
Born to make the Difference
http://khantu.spaces.msn.com
---------------------------------------------
The weak can never forgive. Forgiveness is the attribute of the strong.
''Mahatma Gandhi''


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
First of all thanks for the help ! Now lets assume Test-1 is my first application  and Test-2 is my second application. This is what i did in file called call.jsp in Test-1 application.

                ServletContext ctx2 = application.getContext("/Test-2");
                RequestDispatcher rd = ctx2.getRequestDispatcher("/Test.jsp");
                HttpServletRequest newRequest = new FakeHeadersRequest(request);
                rd.forward(newRequest, response);


Where FakeHeadersRequest is the class which extends HttpServletRequestWrapper  and i have overridden getHeader method as per my requirement. It worked:). I can retrieve the header name in the second application. But when i change it to orbeon perspective i got struck.

If i have a form name called test-form and app name called test-app, the url to access the form would be

http://localhost:8080/orbeon/fr/test-app/test-form/new


So in order to call orbeon form from my first application, i changed the code as


So i changed my code in app1.jsp

               ServletContext ctx2 = application.getContext("/orbeon");
                RequestDispatcher rd = ctx2.getRequestDispatcher("/fr/test-app/test-form/new");
                HttpServletRequest newRequest = new FakeHeadersRequest(request);
                rd.forward(newRequest, response);

But when i hit the app1.jsp, what i get is a blank page in orbeon. In the server log i get the following info.

16:45:40,908 INFO  [ProcessorService] /fr/Dynamic-DataSource-Application/Dynamic-DataSource-Form/new/ - Received request

Apart from this info, no other information is available in the log. The result is just a blank page. Please help !!!

Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
Any help please .. .

Today i checked with


 ServletContext ctx2 = application.getContext("/orbeon");
 RequestDispatcher rd = ctx2.getRequestDispatcher("/xforms-jsp/flickr-search/service-search.jsp");
 HttpServletRequest newRequest = new FakeHeadersRequest(request);
 rd.forward(newRequest, response);

Its working. But y cant i call a form? using the following code. Am i doing anything wrong here ??
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
I need to check the dynamic datasource support of orbeon. But due to this issue i am unable to proceed. Anny help invited ! Thanks !
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

Gaurav Shah
Can you please send your FakeRequest Java file?
 
Gaurav Shah

On Fri, Jun 25, 2010 at 4:40 AM, karthik Jayaraman <[hidden email]> wrote:

I need to check the dynamic datasource support of orbeon. But due to this
issue i am unable to proceed. Anny help invited ! Thanks !
--
View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Dynamic-datasource-support-in-orbeon-Help-tp2248429p2268211.html
Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
Gaurav Shah
Born to make the Difference
http://khantu.spaces.msn.com
---------------------------------------------
The weak can never forgive. Forgiveness is the attribute of the strong.
''Mahatma Gandhi''


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
S. I have attached that file with this post ! But i can receive the request header when using some other sample application. But when using orbeon i could not even manage to navigate to the form !

Thanks for the response !

--------------------------FILE -----------------------------------------

CustomRequest.java 
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
I am struck up with this problem for quite a few days! help!
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

Gaurav Shah
Overall everything looked fine with your FakeRequest java file. I am assuming that dispatcher.forward() worked with original request without dynamic data source. Now, the questions comes to my mind are  1) you are sure that you have data source configured properly with the header value that you are returning? Do you have anything in logs?
Other than this, I am out of ideas at the moment.
 
Gaurav Shah

On Fri, Jun 25, 2010 at 9:47 PM, karthik Jayaraman <[hidden email]> wrote:

I am struck up with this problem for quite a few days! help!
--
View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Dynamic-datasource-support-in-orbeon-Help-tp2248429p2269155.html
Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
Gaurav Shah
Born to make the Difference
http://khantu.spaces.msn.com
---------------------------------------------
The weak can never forgive. Forgiveness is the attribute of the strong.
''Mahatma Gandhi''


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
The problem is i am not checking the dynamic data source feature now. What i am trying to do is set a request header and pass it to a orbeon form. If this works out then i should have no problem in implementing Dynamic datasource support provided by orbeon. The unanswered questions now are,

1. Why am i not able to forward the request to the orbeon form? Why am i getting a blank page? If i can forward the request to a page inside orbeon/web-inf/xforms-jsp folder, why cant i forward my request to a orbeon form retrieved from the database.

I hope Alessandro Vernet should look at my unanswered questions and try to provide me some inputs on this problem. Coz i cant solve this problem for about 2 weeks now !

I would really appreciate any help ! Thanks .................
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

Alessandro  Vernet
Administrator
Karthik,

Just checking: do you have:

    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>

In your <filter-mapping>, in web.xml?

Alex

On Sun, Jun 27, 2010 at 9:16 PM, karthik Jayaraman <[hidden email]> wrote:

>
> The problem is i am not checking the dynamic data source feature now. What i
> am trying to do is set a request header and pass it to a orbeon form. If
> this works out then i should have no problem in implementing Dynamic
> datasource support provided by orbeon. The unanswered questions now are,
>
> 1. Why am i not able to forward the request to the orbeon form? Why am i
> getting a blank page? If i can forward the request to a page inside
> orbeon/web-inf/xforms-jsp folder, why cant i forward my request to a orbeon
> form retrieved from the database.
>
> I hope Alessandro Vernet should look at my unanswered questions and try to
> provide me some inputs on this problem. Coz i cant solve this problem for
> about 2 weeks now !
>
> I would really appreciate any help ! Thanks .................
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Dynamic-datasource-support-in-orbeon-Help-tp2248429p2270472.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
Orbeon Forms - Web forms, open-source, for the Enterprise -
http://www.orbeon.com/
My Twitter: http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
Yes alex .. i Do
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
This post was updated on .
In reply to this post by Alessandro Vernet
I have attached my application's web.xml with this message.

---------------------Application's web.xml ---------------------

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        id="WebApp_ID" version="2.5">
        <display-name>Test-1</display-name>
        <welcome-file-list>
                <welcome-file>index.html</welcome-file>
                <welcome-file>index.htm</welcome-file>
                <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>


        <filter>
                <filter-name>TestFilter</filter-name>
                <filter-class>com.test.TestFilter</filter-class>
        </filter>

        <filter-mapping>
                <filter-name>TestFilter</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

        <servlet>
                <servlet-name>springapp</servlet-name>
                <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>
       
        <servlet-mapping>
                <servlet-name>springapp</servlet-name>
                <url-pattern>*.htm</url-pattern>
        </servlet-mapping>
       
       
       

<filter>
    <filter-name>orbeon-xforms-filter</filter-name>
    <filter-class>org.orbeon.oxf.servlet.OrbeonXFormsFilter</filter-class>
    <init-param>
        <param-name>oxf.xforms.renderer.context</param-name>
        <param-value>/orbeon</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>orbeon-xforms-filter</filter-name>
    <url-pattern>/xforms-jsp/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

<filter-mapping>
    <filter-name>orbeon-xforms-filter</filter-name>
    <url-pattern>/orbeon/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>


</web-app>


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

karthik Jayaraman
Alessandro ? Any suggestions to resolve this >?
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Re: Dynamic datasource support in orbeon .. Help !!

Alessandro  Vernet
Administrator
In reply to this post by karthik Jayaraman
Karthik,

I got to reproduce that "blank page" symptom by placing the JSP that
does the forward under a path handled by OrbeonXFormsFilter
(/xforms-jsp according to your web.xml):

1. If I place it inside, it does the forward which returns XML (you're
calling the Flickr service), this goes through the filter, which
doesn't do anything with it because it expects XHTML+XForms.
2. So you should place your JSP that does the forwarding outside of
the path handled by OrbeonXFormsFilter. In that case it works, and you
get the XML back in the browser.

Alex

On Mon, Jun 28, 2010 at 10:22 PM, karthik Jayaraman <[hidden email]> wrote:

>
> I have attached orbeon web.xml and my application's web.xml with this
> message.
>
> ---------------------Application's web.xml ---------------------
>
> http://orbeon-forms-ops-users.24843.n4.nabble.com/file/n2271767/web.xml
> web.xml
>
>
> ---------------------orbeon web.xml --------------------------
> http://orbeon-forms-ops-users.24843.n4.nabble.com/file/n2271767/web.xml
> web.xml
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Dynamic-datasource-support-in-orbeon-Help-tp2248429p2271767.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
Orbeon Forms - Web forms, open-source, for the Enterprise -
http://www.orbeon.com/
My Twitter: http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
12