populating an XForm control with a value from lookup table or webservice

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

populating an XForm control with a value from lookup table or webservice

ilango_g
Hi
I have the following use-case:
I have a control for example: DOB and another control called Age:
Based on a value in DOB the age has to be calculated.
I have already done this using XPath.

I feel the same result can be achieved with a Web Service. The WebService (SampleAgeCalculator.java for example)obtains the value of DOB from the DOB control, calculates the age and returns it to the Age control.

How can I use such a service in Orbeon. I have looked up the Orbeon reference material and have come up with the following observations:

1) Use the Delegation processor to call a service implemented as a Web Service
2) With Orbeon already coming with pre-built processors, is it possible to use one of these, rather than having to code my own Java processor.
Well, for now I have my own Java program for  calculating Age - AgeCalculator.java.
Can I just create a processor out of this Java class?


But does this mean that the XML code in my XPL needed to call this Custom Processor will be more complex

I would like to extend the concept emanating from this implementation to other controls as well,
with each of these controls having the ability to reach out to lookup tables or webservices and get their data from?

Please advise.

thanks
ilango
Reply | Threaded
Open this post in threaded view
|

Re: populating an XForm control with a value from lookup table or webservice

Jean Luc-2
There is a sample using web services (see online for the weather one) but
it's somewhat cumbersome to use: you need 2 instances, one with the SOAP
request, another with the response and you bind the controls to the latter.
I'm looking at this as well, I don't have a very good answer yet.

Check the recent archives for a thread "dynamically refreshed model
instances (calling WS from a separate deployment)" - it's related.


----- Original Message -----
From: "ilango_g" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, May 28, 2008 5:03 PM
Subject: [ops-users] populating an XForm control with a value from lookup
table or webservice


>
> Hi
> I have the following use-case:
> I have a control for example: DOB and another control called Age:
> Based on a value in DOB the age has to be calculated.
> I have already done this using XPath.
>
> I feel the same result can be achieved with a Web Service. The WebService
> (SampleAgeCalculator.java for example)obtains the value of DOB from the
> DOB
> control, calculates the age and returns it to the Age control.
>
> How can I use such a service in Orbeon. I have looked up the Orbeon
> reference material and have come up with the following observations:
>
> 1) Use the Delegation processor to call a service implemented as a Web
> Service
> 2) With Orbeon already coming with pre-built processors, is it possible to
> use one of these, rather than having to code my own Java processor.
> Well, for now I have my own Java program for  calculating Age -
> AgeCalculator.java.
> Can I just create a processor out of this Java class?
>
>
> But does this mean that the XML code in my XPL needed to call this Custom
> Processor will be more complex
>
> I would like to extend the concept emanating from this implementation to
> other controls as well,
> with each of these controls having the ability to reach out to lookup
> tables
> or webservices and get their data from?
>
> Please advise.
>
> thanks
> ilango
> --
> View this message in context:
> http://www.nabble.com/populating-an-XForm-control-with-a-value-from-lookup-table-or-webservice-tp17521311p17521311.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
>



--
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: populating an XForm control with a value from lookup table or webservice

fl.schmitt(ops-users)
In reply to this post by ilango_g
hi ilan,

> But does this mean that the XML code in my XPL needed to call this Custom
> Processor will be more complex

I think it wouldn't be more complex - you could call the custom
processor as you would do with any other processor. IMHO it's less
complex to create a custom processor then to expose a web service.

The processor API with examples can be found here:

http://www.orbeon.com/ops/doc/reference-processor-api


florian




--
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: populating an XForm control with a value from lookup table or webservice

Erik Bruchez
Administrator
BTW, Form Builder supports some minimal web service integration, which  
allows you to set data and populate itemsets.

Sorry, no doc on it yet! But the feature is in the builds.

-Erik

On May 29, 2008, at 10:27 AM, Florian Schmitt wrote:

> hi ilan,
>
>> But does this mean that the XML code in my XPL needed to call this  
>> Custom
>> Processor will be more complex
>
> I think it wouldn't be more complex - you could call the custom  
> processor as you would do with any other processor. IMHO it's less  
> complex to create a custom processor then to expose a web service.
>
> The processor API with examples can be found here:
>
> http://www.orbeon.com/ops/doc/reference-processor-api
>
>
> florian
>
>
>
> --
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: populating an XForm control with a value from lookup table or webservice

ilangostl
Thanks for the tips, Florian, Erik, Jean.


On Thu, May 29, 2008 at 6:23 AM, Erik Bruchez <[hidden email]> wrote:
BTW, Form Builder supports some minimal web service integration, which allows you to set data and populate itemsets.

Sorry, no doc on it yet! But the feature is in the builds.

-Erik


On May 29, 2008, at 10:27 AM, Florian Schmitt wrote:

hi ilan,

But does this mean that the XML code in my XPL needed to call this Custom
Processor will be more complex

I think it wouldn't be more complex - you could call the custom processor as you would do with any other processor. IMHO it's less complex to create a custom processor then to expose a web service.

The processor API with examples can be found here:

http://www.orbeon.com/ops/doc/reference-processor-api


florian



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




--
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: populating an XForm control with a value from lookup table or webservice

Bharamani
Hi ilangostl

        Can you share the xpath to calculate age from dob?

        I am trying with this but not working
 
        number(current-date() - . dob)

       Thanks
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: populating an XForm control with a value from lookup table or webservice

Alessandro  Vernet
Administrator
Hi Bharamani,

I imagine you need to know the number of years. This a tricky one. Assuming you want to calculate the age of someone born on xs:date('1974-03-14'), you might be tempted to write:

floor(days-from-duration(current-date() - xs:date('1974-03-14')) div 365)

But this isn't exactly accurate, as not every year has 365 days. Instead, you might want to use:

floor(
  xs:decimal(format-date(current-date(), '[Y].[M01][D01]', (), (), ())) -
  xs:decimal(format-date(xs:date('1974-03-14'), '[Y].[M01][D01]', (), (), ()))
)

Reference: http://stackoverflow.com/a/11942/5295

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet