RE: How best to do a once only calculation?

I'm not sure I believe that calculate and readonly=false work together. 

-----Original Message-----
From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On
Behalf Of Kugelman, John
Sent: Tuesday, June 06, 2006 10:05 AM
To: Mark Birbeck; www-forms@w3.org
Subject: RE: How best to do a once only calculation?


Mark/WG,

Are there any plans to add a @default attribute? It seems like an
obvious thing to do, given this clunky workaround. (No knock against
you, Mark, of course! It's a clever use of existing mechanics.)

John

-----Original Message-----
From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On
Behalf Of Mark Birbeck
Sent: Tuesday, June 06, 2006 11:56 AM
To: www-forms@w3.org
Subject: RE: How best to do a once only calculation?


Adam,

What you're after is much like a 'default' value, which XForms doesn't
support, but can be emulated like this:

  <xforms:bind
   nodeset="Date_begun"
   id="Date_begun"
   type="xsd:dateTime"
   calculate="if(string(text()) = '', now(), text())"
  />

To use this 'default' technique more generally, so that your form users
can
also edit the value, make sure that the readonly MIP is disabled:

  <xforms:bind
   nodeset="how-many-pizzas"
   calculate="if(string(text()) = '', 1, text())"
   readonly="false()"
  />

Regards,

Mark


Mark Birbeck
CEO
x-port.net Ltd.

e: Mark.Birbeck@x-port.net
t: +44 (0) 20 7689 9232
b: http://internet-apps.blogspot.com/
w: http://www.formsPlayer.com/

Download our XForms processor from
http://www.formsPlayer.com/

> -----Original Message-----
> From: www-forms-request@w3.org 
> [mailto:www-forms-request@w3.org] On Behalf Of Flinton Adam
> Sent: 06 June 2006 16:09
> To: www-forms@w3.org
> Subject: How best to do a once only calculation?
> 
> 
> We have a need to put in a date generated when you construct 
> the form as such I have looked at
> 
> <xforms:bind nodeset="Date_begun" id="Date_begun" type="xsd:dateTime"
> calculate="now()" />
> 
> However rather obviously it will do this everytime I open 
> this element/form.
> 
> We have an element which can carry a value which we are using 
> to denote if something is new (i.e. should have the date 
> now() generated) or already existing i.e. it should be left as is.
> 
> 
> Any ideas?
> 
> TIA
> 
> 
> Adam
> 
> This e-mail is confidential and privileged. If you are not 
> the intended recipient please accept our apologies; please do 
> not disclose, copy or distribute information in this e-mail 
> or take any action in reliance on its contents: to do so is 
> strictly prohibited and may be unlawful. Please inform us 
> that this message has gone astray before deleting it. Thank 
> you for your co-operation.
> 
> 
> 
> 

Received on Tuesday, 6 June 2006 18:31:42 UTC