Quantcast

Passing parameters in RestFul web service url of an xforms:submission

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

Passing parameters in RestFul web service url of an xforms:submission

youl
Hi here, and sorry for my English
I'm using Orbeon since 2 weeks and i have a question about the URL resource in
the xforms:submission.
I want to know if this URL could be dynamic?

I mine that, i have field (Code Postal) in my form that i have to pass in the resource URL  (RestFul service)
of an xforms:submission.
for example : http://localhost:8090/RestWebServiceAREG/serviceArchitecte/getCommune/{codePostal}

For now, when i call this service with a default value for this code (ex:http://localhost:8090/RestWebServiceAREG/serviceArchitecte/getCommune/45430),
this service works fine, it bring me a list of department and update my "selectListBox" successfully.

I have read all documentations(wiki) and user guide, but i have not succeed to do this.
Can some body help me on this problem?
Here a piece of my code that i'm unable to do work:

 <xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all">
                <request/>
            </xforms:instance>

            <xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all">
                <response/>
            </xforms:instance>
            <xforms:instance id="test-instance" class="fr-service" xxforms:exclude-result-prefixes="#all">
                <body><champCodePostal/></body>
            </xforms:instance>
            <xforms:submission id="test-submission" class="fr-service"
                               ref="instance('fr-service-request-instance')"
                               action="http://localhost:8090/RestWebServiceAREG/serviceArchitecte/getCommune/{{xxforms:instance('champCodePostal')}}"
                               method="post"
                               serialization="application/xml"
                               mediatype="application/xml"
                               replace="instance"
                               xforms:url-type="resource"                            
                               instance="fr-service-response-instance"/>
            <xforms:action id="FirstAction-binding">
               
                <xforms:action ev:event="xforms-value-changed" ev:observer="champCodePostal-control">
                   
                    <xforms:send submission="test-submission"/>
                </xforms:action>
               
                <xforms:action ev:event="xforms-submit" ev:observer="test-submission">
                   
                    <xxforms:variable name="request-instance-name" select="'test-instance'" as="xs:string"/>
                   
                    <xforms:insert nodeset="instance('fr-service-request-instance')"
                                   origin="saxon:parse(instance($request-instance-name))"/>
                   
                   
                    <xforms:action context="instance('fr-service-request-instance')">
                        <xforms:action class="fr-set-service-value-action">
                   
                            <xxforms:variable name="control-name" select="'champCodePostal'" as="xs:string"/>
                            <xxforms:variable name="path" select="/champCodePostal" as="xs:string"/>
                   
                            <xforms:setvalue ref="$path" value="instance('fr-form-instance')/*/*[name() = $control-name]"/>
                        </xforms:action>
                       
                    </xforms:action>
                </xforms:action>
               
                <xforms:action ev:event="xforms-submit-done" ev:observer="test-submission"
                               context="instance('fr-service-response-instance')">
                    <xforms:action class="fr-itemset-action">
                   
                        <xxforms:variable name="control-name" select="'listeCommune'" as="xs:string"/>
                        <xxforms:variable name="response-items" select="/communes/commune" as="node()*"/>
                   
                        <xxforms:variable name="control-resources" model="fr-resources-model"
                                          select="$fr-form-resources/*[name() = $control-name]"/>
                        <xforms:delete nodeset="$control-resources/item"/>
                        <xforms:action xxforms:iterate="$response-items">
                            <xxforms:variable name="item-label" select="libelle" as="xs:string"/>
                            <xxforms:variable name="item-value" select="codeInsee" as="xs:string"/>
                            <xforms:insert nodeset="$control-resources/*"
                                           origin="xxforms:element('item', (xxforms:element('label', xs:string($item-label)), xxforms:element('value', xs:string($item-value))))"/>
                        </xforms:action>
                    </xforms:action>
                   
                </xforms:action>
            </xforms:action>
           
           
         
           
           

        </xforms:model>
    </xhtml:head>
    <xhtml:body>
        <fr:view>
            <xforms:label ref="instance('fr-form-metadata')/title"/>
            <fr:body>
                <fr:section id="section-1-section" bind="section-1-bind">
                    <xforms:label ref="$form-resources/section-1/label"/>
                    <xforms:help ref="$form-resources/section-1/help"/>
                    <fr:grid columns="2">
                        <xhtml:tr>
                            <xhtml:td>
                                <xforms:input id="control-1-control" bind="control-1-bind">
                                    <xforms:label ref="$form-resources/control-1/label"/>
                                    <xforms:hint ref="$form-resources/control-1/hint"/>
                                    <xforms:help ref="$form-resources/control-1/help"/>
                                    <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                                </xforms:input>
                            </xhtml:td>
                            <xhtml:td/>
                        </xhtml:tr>
                        <xhtml:tr xmlns="http://orbeon.org/oxf/xml/form-builder"
                                  xmlns:xbl="http://www.w3.org/ns/xbl"
                                  xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
                            <xhtml:td>
                               <xforms:input bind="champCodePostal-bind" id="champCodePostal-control" ref="codePostal">
                                    <xforms:label ref="$form-resources/champCodePostal/label"/>
                                    <xforms:hint ref="$form-resources/champCodePostal/hint"/>
                                    <xforms:help ref="$form-resources/champCodePostal/help"/>
                                    <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                                </xforms:input>
                            </xhtml:td>
                            <xhtml:td>
                                <xforms:select1 appearance="minimal" bind="listeCommune-bind" id="listeCommune-control">
                                    <xforms:label ref="$form-resources/listeCommune/label"/>
                                    <xforms:hint ref="$form-resources/listeCommune/hint"/>
                                    <xforms:help ref="$form-resources/listeCommune/help"/>
                                    <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                                    <xforms:itemset nodeset="$form-resources/listeCommune/item">
                                        <xforms:label ref="label"/>
                                        <xforms:value ref="value"/>
                                    </xforms:itemset>
                                </xforms:select1>


Thanks you!

Best regards
--youl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Passing parameters in RestFul web service url of an xforms:submission

Alessandro  Vernet
Administrator
Youl,

I gather that you are changing a form generated by Form Builder? If
that is the case, instead of:

{{xxforms:instance('champCodePostal')}}

I think you will want to write something like:

{xxforms:instance('fr-form-instance')/section-1/codePostal}

Note you only need to double the {{ and }} if your form goes through
XSLT (as a stylesheet), which in general is not the case. Also the
"section-1" is the id of the section that contains that codePostal
field. You might want to change that id to make things clearer. You
can check what is returned by the XPath expression by enabling the
XForms inspector, and using "Evaluate XPath" and pasting the
expression in there with the { and }.

Alex

On Mon, Mar 22, 2010 at 11:44 AM, youl <[hidden email]> wrote:

>
> Hi here, and sorry for my English
> I'm using Orbeon since 2 weeks and i have a question about the URL resource
> in
> the xforms:submission.
> I want to know if this URL could be dynamic?
>
> I mine that, i have field (Code Postal) in my form that i have to pass in
> the resource URL  (RestFul service)
> of an xforms:submission.
> for example :
> http://localhost:8090/RestWebServiceAREG/serviceArchitecte/getCommune/{codePostal}
>
> For now, when i call this service with a default value for this code
> (ex:http://localhost:8090/RestWebServiceAREG/serviceArchitecte/getCommune/45430),
> this service works fine, it bring me a list of department and update my
> "selectListBox" successfully.
>
> I have read all documentations(wiki) and user guide, but i have not succeed
> to do this.
> Can some body help me on this problem?
> Here a piece of my code that i'm unable to do work:
>
>  <xforms:instance id="fr-service-request-instance"
> xxforms:exclude-result-prefixes="#all">
>                <request/>
>            </xforms:instance>
>
>            <xforms:instance id="fr-service-response-instance"
> xxforms:exclude-result-prefixes="#all">
>                <response/>
>            </xforms:instance>
>            <xforms:instance id="test-instance" class="fr-service"
> xxforms:exclude-result-prefixes="#all">
>                <body>&lt;champCodePostal/&gt;</body>
>            </xforms:instance>
>            <xforms:submission id="test-submission" class="fr-service"
>                               ref="instance('fr-service-request-instance')"
>
> action="http://localhost:8090/RestWebServiceAREG/serviceArchitecte/getCommune/{{xxforms:instance('champCodePostal')}}"
>                               method="post"
>                               serialization="application/xml"
>                               mediatype="application/xml"
>                               replace="instance"
>                               xforms:url-type="resource"
>                               instance="fr-service-response-instance"/>
>            <xforms:action id="FirstAction-binding">
>
>                <xforms:action ev:event="xforms-value-changed"
> ev:observer="champCodePostal-control">
>
>                    <xforms:send submission="test-submission"/>
>                </xforms:action>
>
>                <xforms:action ev:event="xforms-submit"
> ev:observer="test-submission">
>
>                    <xxforms:variable name="request-instance-name"
> select="'test-instance'" as="xs:string"/>
>
>                    <xforms:insert
> nodeset="instance('fr-service-request-instance')"
>
> origin="saxon:parse(instance($request-instance-name))"/>
>
>
>                    <xforms:action
> context="instance('fr-service-request-instance')">
>                        <xforms:action class="fr-set-service-value-action">
>
>                            <xxforms:variable name="control-name"
> select="'champCodePostal'" as="xs:string"/>
>                            <xxforms:variable name="path"
> select="/champCodePostal" as="xs:string"/>
>
>                            <xforms:setvalue ref="$path"
> value="instance('fr-form-instance')/*/*[name() = $control-name]"/>
>                        </xforms:action>
>
>                    </xforms:action>
>                </xforms:action>
>
>                <xforms:action ev:event="xforms-submit-done"
> ev:observer="test-submission"
>
> context="instance('fr-service-response-instance')">
>                    <xforms:action class="fr-itemset-action">
>
>                        <xxforms:variable name="control-name"
> select="'listeCommune'" as="xs:string"/>
>                        <xxforms:variable name="response-items"
> select="/communes/commune" as="node()*"/>
>
>                        <xxforms:variable name="control-resources"
> model="fr-resources-model"
>
> select="$fr-form-resources/*[name() = $control-name]"/>
>                        <xforms:delete nodeset="$control-resources/item"/>
>                        <xforms:action xxforms:iterate="$response-items">
>                            <xxforms:variable name="item-label"
> select="libelle" as="xs:string"/>
>                            <xxforms:variable name="item-value"
> select="codeInsee" as="xs:string"/>
>                            <xforms:insert nodeset="$control-resources/*"
>                                           origin="xxforms:element('item',
> (xxforms:element('label', xs:string($item-label)), xxforms:element('value',
> xs:string($item-value))))"/>
>                        </xforms:action>
>                    </xforms:action>
>
>                </xforms:action>
>            </xforms:action>
>
>
>
>
>
>
>        </xforms:model>
>    </xhtml:head>
>    <xhtml:body>
>        <fr:view>
>            <xforms:label ref="instance('fr-form-metadata')/title"/>
>            <fr:body>
>                <fr:section id="section-1-section" bind="section-1-bind">
>                    <xforms:label ref="$form-resources/section-1/label"/>
>                    <xforms:help ref="$form-resources/section-1/help"/>
>                    <fr:grid columns="2">
>                        <xhtml:tr>
>                            <xhtml:td>
>                                <xforms:input id="control-1-control"
> bind="control-1-bind">
>                                    <xforms:label
> ref="$form-resources/control-1/label"/>
>                                    <xforms:hint
> ref="$form-resources/control-1/hint"/>
>                                    <xforms:help
> ref="$form-resources/control-1/help"/>
>                                    <xforms:alert
> ref="$fr-resources/detail/labels/alert"/>
>                                </xforms:input>
>                            </xhtml:td>
>                            <xhtml:td/>
>                        </xhtml:tr>
>                        <xhtml:tr
> xmlns="http://orbeon.org/oxf/xml/form-builder"
>                                  xmlns:xbl="http://www.w3.org/ns/xbl"
>
> xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
>                            <xhtml:td>
>                               <xforms:input bind="champCodePostal-bind"
> id="champCodePostal-control" ref="codePostal">
>                                    <xforms:label
> ref="$form-resources/champCodePostal/label"/>
>                                    <xforms:hint
> ref="$form-resources/champCodePostal/hint"/>
>                                    <xforms:help
> ref="$form-resources/champCodePostal/help"/>
>                                    <xforms:alert
> ref="$fr-resources/detail/labels/alert"/>
>                                </xforms:input>
>                            </xhtml:td>
>                            <xhtml:td>
>                                <xforms:select1 appearance="minimal"
> bind="listeCommune-bind" id="listeCommune-control">
>                                    <xforms:label
> ref="$form-resources/listeCommune/label"/>
>                                    <xforms:hint
> ref="$form-resources/listeCommune/hint"/>
>                                    <xforms:help
> ref="$form-resources/listeCommune/help"/>
>                                    <xforms:alert
> ref="$fr-resources/detail/labels/alert"/>
>                                    <xforms:itemset
> nodeset="$form-resources/listeCommune/item">
>                                        <xforms:label ref="label"/>
>                                        <xforms:value ref="value"/>
>                                    </xforms:itemset>
>                                </xforms:select1>
>
>
> Thanks you!
>
> Best regards
> --youl
> --
> View this message in context: http://n4.nabble.com/Passing-parameters-in-RestFul-web-service-url-of-an-xforms-submission-tp1678112p1678112.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
|  
Report Content as Inappropriate

Re: Passing parameters in RestFul web service url of an xforms:submission

youl
In reply to this post by youl
Hi here,
thank u very much for your help.
Your solution fix my problem.
thx a lot
Loading...