Load initial data - Not working

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

Load initial data - Not working

Vedha
Below is my sample XForm,

<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/>
                    <last-name/>
                </registration>
            </xf:instance>

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

        </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>



Here is how i am calling the code

http://localhost:8080/orbeon/xforms-espresso/?my-user-data=%3Cregistration%3E%3Cfirst-name%3EVedhagiri%3C/first-name%3E%3C/registration%3E,

My expectation is, the First Name "Vedhagiri" should be loading in the browser? This is not working, what am i missing in this???


I am sending the my-user-date in request parameter.
Reply | Threaded
Open this post in threaded view
|

Re: Load initial data - Not working

Alessandro  Vernet
Administrator
Hi Vedha,

Adding a xmlns:saxon="http://saxon.sf.net/" on the root element,
change your xf:insert as follows:

<xf:insert ev:event="xforms-model-construct-done"
    ref="instance('user-data')"
    origin="saxon:parse(xxf:get-request-parameter('my-user-data'))" />

And on the URL, pass
?my-user-data=<registration><first-name>Vedhagiri</first-name></registration>.
That should do the trick. However, note that this can be a security
risk, as you're allowing a user to set entire XML data structure.
Also, you can run into issue if the data is too large, as browsers and
servers alike have limits on how much data can be passed through
request parameters.

Alex

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

> Below is my sample XForm,
>
> <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/>
>                     <last-name/>
>                 </registration>
>             </xf:instance>
>
>
>             <xf:insert ev:event="xforms-model-construct-done"
>                            ref="instance('user-data')"
> origin="xxf:get-request-attribute('my-user-data')"/>
>
>         </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>
>
>
>
> Here is how i am calling the code
>
> http://localhost:8080/orbeon/xforms-espresso/?my-user-data=%3Cregistration%3E%3Cfirst-name%3EVedhagiri%3C/first-name%3E%3C/registration%3E,
>
> My expectation is, the First Name "Vedhagiri" should be loading in the
> browser? This is not working, what am i missing in this???
>
>
> I am sending the my-user-date in request parameter.
>
> --
> View this message in context: http://discuss.orbeon.com/Load-initial-data-Not-working-tp4659835.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