atom feed9 messages in org.mozilla.lists.dev-tech-xformsRE: Formatting currency in XForms
FromSent OnAttachments
DanDec 7, 2006 8:31 am 
Marco LettereDec 7, 2006 8:49 am 
Aaron ReedDec 7, 2006 9:30 am 
Klotz, LeighDec 7, 2006 2:51 pm 
Josef SpillnerDec 8, 2006 12:23 am 
Alexander SurkovDec 8, 2006 4:52 am 
Klotz, LeighDec 8, 2006 9:34 am 
Klotz, LeighDec 8, 2006 1:42 pm 
DanDec 9, 2006 1:09 pm 
Subject:RE: Formatting currency in XForms
From:Klotz, Leigh (Leig@xerox.com)
Date:Dec 8, 2006 9:34:49 am
List:org.mozilla.lists.dev-tech-xforms

I was quite wrong about Mozilla not having a way to select CSS on the basis of bound type!

I had missed an email message due to an overactive filter, and didn't find out about the Mozilla typelist CSS feature described here: http://developer.mozilla.org/en/docs/XForms:Custom_Controls#Custom_Data_ Types

Thank you to Aaron Reed for pointing it out to me. I find this quite spectacularly nice.

So, based on the above documentation and http://developer.mozilla.org/en/docs/XForms:Custom_Controls a custom date control could be written something like this:

---foo.xhtml--- ...<xf:bind nodeset="date" type="xsd:date" /> <link rel="StyleSheet" type="text/css" href="output.css" /> <xf:output ref="date"/>... ---output.css--- @namespace xf url(http://www.w3.org/2002/xforms); @namespace mozType url(http://www.mozilla.org/projects/xforms/2005/type); xf|output[mozType|typelist~="http://www.w3.org/2001/XMLSchema#date"] { -moz-binding: url('bindings.xml#output-date'); } ---bindings.xml--- <?xml version="1.0"?> <bindings id="xformsBindings" xmlns="http://www.mozilla.org/xbl" xmlns:html="http://www.w3.org/1999/xhtml"> <binding id="output-date" extends="chrome://xforms/content/xforms.xml#xformswidget-base"> <content> <html:span anonid="content" /> </content> <implementation implements="nsIXFormsUIWidget"> <method name="refresh"> <body> var span = document.getAnonymousElementByAttribute(this, "anonid", "content"); if (span) { var date = new Date(); // this line depends on the setISO8601 package from http://delete.me.uk/2005/03/iso8601.html date.setISO8601(this.stringValue); var str = date.toLocaleString(); // crock for removing "Monday, " if present; not I18N. var idx = str.indexOf("day, "); if (idx != -1) { str = str.substring(idx+5); } span.textContent = str; } return true; </body> </method> </implementation> </binding> </bindings>