We could add system.include() when the stub is used in the Mashup Server,
but there isn't AFIACT a similar capability within the browser. Even if
there was it would be a pain to make it work without errors or warnings
across the two environments.
The functions aren't that elaborate, but I have used them in a number of
mashups I've written so I'd like to publish their existence to stub users
since they are available.
Currently you can do
var d = new Date().parseXsDateTime("2008-01-01T01:02:03Z");
d.setUTCYear(d.getUTCYear + 1);
return d.toXsDateTime();
With a util class it might look like:
var d = WebService.util.parseXsDateTime ("2008-01-01T01:02:03Z");
d.setUTCYear(d.getUTCYear + 1);
return WebService.util.toXsDateTime(d);
The big consideration IMO is keeping the namespaces clean so you can use the
stub in conjunction with other libraries. The first pollutes the Date
object which may cause problems with other libraries (we ran into this with
prototype.js and YUI.) The second scopes the util to the WebService object
which we hope doesn't conflict with other libraries (if it does we're
already sunk.)
Jonathan Marsh - http://www.wso2.com - http://auburnmarshes.spaces.live.com
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of Keith Chapman
> Sent: Sunday, March 30, 2008 8:54 PM
> To: mashup-dev
> Subject: Re: [mashup-dev] Extending Date prototype
>
> How about including these inbuilt JS-function libraries by default?
>
> Thanks,
> Keith.
>
> Jonathan Marsh wrote:
> > These functions are required by the stub, so I don't want them in a
> separate
> > file where one can forget to include them.
> >
> > Jonathan Marsh - http://www.wso2.com -
> http://auburnmarshes.spaces.live.com
> >
> >
> >> -----Original Message-----
> >> From: [EMAIL PROTECTED] [mailto:mashup-dev-
> [EMAIL PROTECTED]
> >> On Behalf Of Keith Chapman
> >> Sent: Friday, March 28, 2008 9:31 PM
> >> To: [email protected]
> >> Subject: Re: [mashup-dev] Extending Date prototype
> >>
> >> I like the concept of having some utility js functions. May be we
> drop
> >> them into some common directory where all mashups have access to. If
> we
> >> have that in place we can ship more utility js libraries.
> >>
> >> Thanks,
> >> Keith.
> >>
> >> Jonathan Marsh wrote:
> >>> The latest stubs include extensions to the Date object to parse and
> >>> serialize xs:date, xs:time, and xs:dateTime types. I implemented
> >> these as
> >>> extension methods for convenient, because these methods can be used
> >> by any
> >>> stub user (they're not just internal).
> >>>
> >>>
> >>>
> >>> However I don't think extending build-in objects is viewed as a
> good
> >>> practice - for instance it could conflict with other JS libraries.
> >>>
> >>>
> >>>
> >>> What do you think? Should I reformulate these are util methods of
> >> some
> >>> kind? Hide them from the public? Or is the current state good
> >> enough?
> >>>
> >>>
> >>> Jonathan Marsh - <http://www.wso2.com> http://www.wso2.com -
> >>> <http://auburnmarshes.spaces.live.com>
> >> http://auburnmarshes.spaces.live.com
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> -------------------------------------------------------------------
> --
> >> ---
> >>> _______________________________________________
> >>> Mashup-dev mailing list
> >>> [email protected]
> >>> http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
> >>
> >> _______________________________________________
> >> Mashup-dev mailing list
> >> [email protected]
> >> http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
> >
> >
>
>
> _______________________________________________
> Mashup-dev mailing list
> [email protected]
> http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev