Rather than posting the whole thing, I have already done a post at
mozilla xforms forum (but I wanted some advice from an xbl expert so
that's why I'm posting here. )
here is that link to my topic "xforms-hide" in the mozilla Xforms
forum:
http://groups.google.com/group/mozilla.dev.tech.xforms/browse_thread/thread/64f1397493dd9c38#
any advice, help, or direction is appreciated
I have a few examples here:
http://en.wikibooks.org/wiki/XForms/Custom_Controls
But to be honest I can't get most of my examples to work. I have been
working on a simple bind for currency formatting (input= 123.456.78
and $123,450.78) that still does not work right.
Any suggestions you have on learning XBL would be appreciated.
HI Dan,
I tried to do some simple things with XBL just to see if I could
figure out the basics and I got nowhere. So I have a serious learning
curve going on here. Not sure if I can afford to invest the time to
learn right now.
There don't seem to be any good basic tutorial with xbl (if I knew
xul, I might could follow the mozilla xul tutorial, but I can't seem
to translate this to use with xforms).
Here's my first attempt at xbl. I tried following several different
tutorials and this is the best I could do.
Of course, it doesn't work on whit. All I'm trying to do is put in
one element in the place of a whole set of switch/case elements. You
can see, there's only one element in the xhtml body.
Any suggestions?
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:html
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events">
<h:head>
<h:title>Test XBL</h:title>
<xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events" >
<xbl:binding id="hide1">
<xbl:content>
<xf:switch>
<xf:case id="closed">
<xf:trigger appearance="minimal">
<xf:label>:: toggle ::</xf:label>
<xf:toggle case="view" ev:event="DOMActivate"/>
</xf:trigger>
</xf:case>
<xf:case id="view">
<xf:trigger appearance="minimal">
<xf:label>:: toggle ::</xf:label>
<xf:toggle case="closed" ev:event="DOMActivate"/>
</xf:trigger>
<xf:group>!!!!!!FORM CONTENT HERE!!!!!!</xf:group>
</xf:case>
</xf:switch>
</xbl:content>
</xbl:binding>
</xbl:bindings>
<h:style type="text/css">
@namespace xf url(http://www.w3.org/2002/xforms);
xf|hide.hide1 {
-moz-binding: url('#hide1');
}
</h:style>
</h:head>
<h:body>
<xf:group class="hide1"/>
</h:body>
</h:html>
Your XBL needs to have insertion points for all the kids of the content. That
is, you need a <children/> tag somewhere in your <content>. If you don't want
them to show up, put it in a parent with display:none.
-Boris
Thanks Boris
It still doesn't work as expected, however, as you pointed out, I
needed the children element and I got it to at least display
the ::toggle:: , although it doesn't actually toggle. Also, I noticed
in my css that I forgot to change my xf|hide.hide1 to xf|
group.hide1.
I think, however, that the xforms toggle can't actually work in a case
like this.
I did just notice that if I completely remove the first case (the
entire element and all its children), then the second case will
display, and vice versa. But they don't seem to work together.
Here are some things I came to notice. It seems that for now xforms
action elements will not work in xbl
the xbl 2.0 spec says:
It is theoretically possible to use XForms Actions as the scripting
language in XBL [XFORMS]. The MIME type that indicates this scripting
language is tentatively defined to be application/x-xforms-actions
+xml. XBL elements have the following semantics when used with XForms
Actions:
[ see link for more details: 3.2.1 xforms action http://www.w3.org/TR/2006/WD-xbl-20060619/
]
However, it will work perfectly fine with display elements, and of
course, you can do other scripting in place of the xforms-action
elements if you are so inclined.
Here is some code that shows it's use. You'll notice that I had to
pull out the xforms-setvalue elements from the xbl binding, but
leaving in the xforms-trigger was fine. This code may not be very
useful, the only advantage it might have is that you can rid your main
document of some clutter by putting the other elements in xbl. But at
any rate, you can get some idea of how xbl currently works (at basic
level).
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:html
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:cr="http://www.cr.org/2008/markups">
<h:head>
<h:title>Test XBL</h:title>
<xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:cr="http://www.cr.org/2008/markups">
<xbl:binding id="hide">
<xbl:content>
<xf:trigger ev:event="DOMActivate">
<xf:label>:: hide ::</xf:label>
<xbl:children includes="xf:setvalue"/>
</xf:trigger>
<xf:group bind="toGleRelv">
<xbl:children/>
</xf:group>
</xbl:content>
</xbl:binding>
</xbl:bindings>
<xf:model>
<xf:instance xmlns="">
<data>
<toGleRelv/>
<toGle>open</toGle>
</data>
</xf:instance>
<xf:bind id="toGleRelv" nodeset="//toGleRelv" relevant="//
toGle='open'"/>
</xf:model>
<h:style type="text/css">
@namespace xf url(http://www.w3.org/2002/xforms);
xf|group.hide { -moz-binding: url('#hide'); }
</h:style>
</h:head>
<h:body>
<xf:group class="hide">
<xf:setvalue ev:event="DOMActivate" ref="//toGle"
value="if(.='open','shut','open')"/>
<h:p>Show me the money!</h:p>
</xf:group>
</h:body>
</h:html>