load initial data - Push solution - Example

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

load initial data - Push solution - Example

Vedha
Can anyone help by posting a sample java httpClient program that calls the Orbeon with request attribute?
Reply | Threaded
Open this post in threaded view
|

Re: load initial data - Push solution - Example

Alessandro  Vernet
Administrator
Hi Vedha,

Could you tell us more about what you are trying to do? Typically, it
is forms that call services, nio the other way around.

Alex

On Wed, Apr 22, 2015 at 4:34 PM, Vedha <[hidden email]> wrote:

> Can anyone help by posting a sample java httpClient program that calls the
> Orbeon with request attribute?
>
> --
> View this message in context: http://discuss.orbeon.com/load-initial-data-Push-solution-Example-tp4659834.html
> Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.
>
> --
> 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].

--
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].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: load initial data - Push solution - Example

Vedha
Here is what we are trying to do,

Our xForms,

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events">
    <head>
        <title>Push initial form data to XForms from Java</title>
        <xf:model>

           
            <xf:instance id="user-data">
                <registration xmlns="">
                    <first-name></first-name>
                    <last-name/>
                </registration>
            </xf:instance>

           
           

           
            <xf:insert ev:event="xforms-model-construct-done"
                           ref="instance('user-data')" origin="xxf:get-session-attribute('firstname')"/>
                           
           

        </xf:model>
        <style type="text/css"> .xforms-label { display: block; } fieldset { width: 15em; margin-top: 1em; } </style>    </head>
    <body>
        <fieldset>
            <legend>Registration</legend>
            <xf:input ref="first-name">
                <xf:label>First name</xf:label>
            </xf:input>
            <xf:input ref="last-name">
                <xf:label>Last name</xf:label>
            </xf:input>
        </fieldset>
    </body>
</html>



I am calling this Form from Java code like this and expecting the instance to be replaced with request parater(my-user-data), but it is not getting replaced. Please help,

                List<NameValuePair> params = new LinkedList<NameValuePair>();


                String dataXml = "<registration><first-name>Vedhagiri</first-name></registration>";

// params.add(new BasicNameValuePair("my-user-data", "Vedhagiri"));

// String encoded = URLEncodedUtils.

                String url = "http://localhost:8080/orbeon/xforms-espresso/?" + "my-user-data=" + dataXml;

// HttpGet httpget = new HttpGet(url);
                System.out.println(url);


                HttpGet get = new HttpGet(url);
                get.addHeader("User-Agent", USER_AGENT);
                HttpResponse response = client.execute(get);
                BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                String inputLine;
                StringBuffer response1 = new StringBuffer();

                while ((inputLine = in.readLine()) != null) {
                        response1.append(inputLine);
                }
                in.close();

                PrintWriter printWriter = new PrintWriter(new File("C:\\database\\sample.txt"));
                printWriter.print(response1);
                printWriter.close();
Reply | Threaded
Open this post in threaded view
|

Re: load initial data - Push solution - Example

Alessandro  Vernet
Administrator
Hi Vedha,

Got it, then the method described in this thread should do it:

http://discuss.orbeon.com/Load-initial-data-Not-working-td4659835.html

And if this is indeed the same question, I suggest we continue the
discussion on that other thread.

Alex

On Thu, Apr 23, 2015 at 11:50 AM, Vedha <[hidden email]> wrote:

> Here is what we are trying to do,
>
> Our xForms,
>
> <html xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:xf="http://www.w3.org/2002/xforms"
>       xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
>       xmlns:ev="http://www.w3.org/2001/xml-events">
>     <head>
>         <title>Push initial form data to XForms from Java</title>
>         <xf:model>
>
>
>             <xf:instance id="user-data">
>                 <registration xmlns="">
>                     <first-name></first-name>
>                     <last-name/>
>                 </registration>
>             </xf:instance>
>
>
>
>
>
>             <xf:insert ev:event="xforms-model-construct-done"
>                            ref="instance('user-data')"
> origin="xxf:get-session-attribute('firstname')"/>
>
>
>
>         </xf:model>
>
>     </head>
>     <body>
>         <fieldset>
>             <legend>Registration</legend>
>             <xf:input ref="first-name">
>                 <xf:label>First name</xf:label>
>             </xf:input>
>             <xf:input ref="last-name">
>                 <xf:label>Last name</xf:label>
>             </xf:input>
>         </fieldset>
>     </body>
> </html>
>
>
>
> I am calling this Form from Java code like this and expecting the instance
> to be replaced with request parater(my-user-data), but it is not getting
> replaced. Please help,
>
>                 List<NameValuePair> params = new LinkedList<NameValuePair>();
>
>
>                 String dataXml =
> "<registration><first-name>Vedhagiri</first-name></registration>";
>
> //              params.add(new BasicNameValuePair("my-user-data", "Vedhagiri"));
>
> //              String encoded = URLEncodedUtils.
>
>                 String url = "http://localhost:8080/orbeon/xforms-espresso/?" +
> "my-user-data=" + dataXml;
>
> //              HttpGet httpget = new HttpGet(url);
>                 System.out.println(url);
>
>
>                 HttpGet get = new HttpGet(url);
>                 get.addHeader("User-Agent", USER_AGENT);
>                 HttpResponse response = client.execute(get);
>                 BufferedReader in = new BufferedReader(new
> InputStreamReader(response.getEntity().getContent()));
>                 String inputLine;
>                 StringBuffer response1 = new StringBuffer();
>
>                 while ((inputLine = in.readLine()) != null) {
>                         response1.append(inputLine);
>                 }
>                 in.close();
>
>                 PrintWriter printWriter = new PrintWriter(new
> File("C:\\database\\sample.txt"));
>                 printWriter.print(response1);
>                 printWriter.close();
>
> --
> View this message in context: http://discuss.orbeon.com/load-initial-data-Push-solution-Example-tp4659834p4659839.html
> Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.
>
> --
> 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].

--
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].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet