Using HTTP 'GET' Parameters within Orbeon

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

Using HTTP 'GET' Parameters within Orbeon

Alex Bleasdale
Hi,

I'm hoping someone can help -

I've looked around and haven't been able to find a working solution for this, so I thought I'd post to the forum to see if anyone can assist.  I'm hoping to be able to pass parameters to the xform when I call the page, so I'd like to be able to do something like this:

http://localhost:8080/orbeon/xforms-get-example/?id=1234&id2=5678

I've found 2 promising looking solutions - although I've not had success getting either of them to work properly and I'm hoping someone can offer some suggestions re: either approach.

1st solution (using Orbeon 3.6) and the Page Flow Controller:

I had a look at the example on the page here:

http://www.orbeon.com/ops/doc/reference-page-flow#url-extraction

And I've edited my page-flow.xml to try and 'pull' those parameters out like this:

    <page path-info="*" view="view.xhtml" default-submission="/resources/test.xml">
        <setvalue ref="/submission/first" parameter="id"/>
        <setvalue ref="/submission/second" parameter="id2"/>
    </page>


And I've created an 'empty' test.xml file like this:

<?xml version="1.0" encoding="UTF-8"?>
<submission>
    <first/>
    <second/>
</submission>


When I call the page, I get no errors - but I'm not sure how I can access those parameters.  The form loads but I'm guessing I need to do something else to make those parameters available?  The only thing I could think of trying was to add test.xml as an instance in the model - but of course all that did was literally just add the contents of the empty file.  Can anyone point me in the right direction regarding what I can try next with this?  Thanks so much.

2nd solution (using the Orbeon 3.7 nightly build):

After a bit more digging, I discovered that Orbeon 3.7 had a new feature called xxforms:get-request-parameter

I grabbed the current nightly build, deployed it, created an instance called 'params' in my page, I saw in the documentation (http://www.orbeon.com/ops/doc/reference-xforms-2) that you could run xxforms:get-request-parameter from the event 'xforms-model-construct-done', so I created this block of code in my model:


        <xf:action ev:event="xforms-model-construct-done">
            <xxforms:script ev:event="DOMActivate">weAreDone();</xxforms:script>
           
            <xf:setvalue ref="instance('params')/one" select="xxforms:get-request-parameter('id')" /> 
         </xf:action>


Now I tried hardcoding value of the ref with setvalue and that seemed to work just fine, but when I use the select="xxforms:get-request-parameter('id')" all I seem to end up with is an empty closed tag (<one />) in my instance.

Can anyone please offer any advice regarding either of these solutions?  

Thanks so much,
A
Reply | Threaded
Open this post in threaded view
|

Re: Using HTTP 'GET' Parameters within Orbeon

fitek

Hi,

the way I have gotten parameters into my XForms:

In my page-flow:

<page path-info="/myapp/mypage"
        view="mypage.xhtml"
        default-submission="parameters.xml" >
        <setvalue ref="/parameters/testId" parameter="testId"/>
        <setvalue ref="/parameters/dummy"      parameter="dummy"/>
</page>


parameters.xml is just:

<parameters>
        <testId/>
        <dummy/>
</parameters>

Now to access this data inside mypage.xhtml I just put the following whereever
I use the parameter:

{doc('input:instance')/parameters/testId}

I can access my page in the browser by typing
http://myip/myapp/mypage?testId=1&dummy=foo

This is using Orbeon 3.6.0.


--
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: Using HTTP 'GET' Parameters within Orbeon

Erik Bruchez
Administrator
In reply to this post by Alex Bleasdale
> When I call the page, I get no errors - but I'm not sure how I can  

> access
> those parameters.  The form loads but I'm guessing I need to do  
> something
> else to make those parameters available?  The only thing I could  
> think of
> trying was to add test.xml as an instance in the model - but of  
> course all
> that did was literally just add the contents of the empty file.  Can  
> anyone
> point me in the right direction regarding what I can try next with  
> this?
> Thanks so much.
You can access that document using:

   <xforms:instance src="input:instance"/>

See:

   http://www.orbeon.com/ops/doc/reference-xforms-ng#xforms-instance-initialization-src

>            <xf:setvalue ref="instance('params')/one"
> select="xxforms:get-request-parameter('id')" />
>         </xf:action>
>
>
> Now I tried hardcoding value of the ref with setvalue and that  
> seemed to
> work just fine, but when I use the
> select="xxforms:get-request-parameter('id')" all I seem to end up  
> with is an
> empty closed tag (<one />) in my instance.

An easy one: xforms:setvalue doesn't have a @select attribute, it has  
a @value attribute.

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.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
Reply | Threaded
Open this post in threaded view
|

Re: Using HTTP 'GET' Parameters within Orbeon

Alex Bleasdale
In reply to this post by Alex Bleasdale
Hi,

Thanks to both of you for those suggestions - with your help I've been able to get both methods working successfully - thanks so much: I really appreciate your time and your help.

Erik,

> An easy one: xforms:setvalue doesn't have a @select attribute, it has a @value attribute.

Thanks so much for pointing this out - I wish I'd tried that before posting to the forum!

Just a minor comment though:

In the documentation for xxforms:get-request-parameter (at http://www.orbeon.com/ops/doc/reference-xforms-2), the example listed uses the @select attribute rather than the @value attribute; maybe it would be useful to switch those?

Thanks again.
A
Reply | Threaded
Open this post in threaded view
|

Re: Re: Using HTTP 'GET' Parameters within Orbeon

Erik Bruchez
Administrator
Alex,

Glad to hear that sometimes we actually do manage to help users ;-)

-Erik

On May 9, 2008, at 11:59 AM, Alex Bleasdale wrote:

>
> Hi,
>
> Thanks to both of you for those suggestions - with your help I've  
> been able
> to get both methods working successfully - thanks so much: I really
> appreciate your time and your help.
>
> Erik,
>
>> An easy one: xforms:setvalue doesn't have a @select attribute, it  
>> has a
>> @value attribute.
>
> Thanks so much for pointing this out - I wish I'd tried that before  
> posting
> to the forum!
>
> Just a minor comment though:
>
> In the documentation for xxforms:get-request-parameter (at
> http://www.orbeon.com/ops/doc/reference-xforms-2), the example  
> listed uses
> the @select attribute rather than the @value attribute; maybe it  
> would be
> useful to switch those?
>
> Thanks again.
> A
> --
> View this message in context: http://www.nabble.com/Using-HTTP-%27GET%27-Parameters-within-Orbeon-tp17151311p17154564.html
> Sent from the ObjectWeb 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 for the Enterprise Done the Right Way
http://www.orbeon.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