Re: XForms disappointed beginner

Aaron Reed <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xml
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Alex Meyers wrote:

> Got XForms working on Mozilla, took some time to convince IIS to serve it 
> correctly :)
> Now I got a little test form, nothing really complicated, which I 
> constructed with XFormation editor
> 
> formsPlayer version
> 
> <?xml version="1.0" encoding="utf-8"?>
> <html xmlns:fp="urn:formsplayer.com" xmlns="http://www.w3.org/1999/xhtml" 
> xmlns:xf="http://www.w3.org/2002/xforms" 
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>  <head>
>   <object width="0" height="0" id="FormsPlayer" 
> classid="CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58">
>    <b>FormsPlayer has failed to load! Please check your installation.</b>
>   </object>
>   <?import namespace="xf" implementation="#FormsPlayer"?>
>   <xf:model>
>    <xf:instance id="Data">
>     <Data>
>      <ReadOnly>1</ReadOnly><Required>2</Required><Relevant>3</Relevant><Calculate>4</Calculate><Constraint>5</Constraint>
>     </Data>
>    </xf:instance>
>    <xf:bind nodeset="/Data/*" type="xs:integer" id="DataInteger" />
>    <xf:bind id="ReadOnly" readonly="true()" nodeset="ReadOnly" />
>    <xf:bind id="Required" required="true()" nodeset="Required" />
>    <xf:submission id="SaveLocal" action="./savelocal.xml" method="put" 
> replace="none" ref="/" />
>    <xf:bind nodeset="Calculate" calculate="../ReadOnly * ../Required" />
>   </xf:model>
>  </head>
>  <body>
>   <p><xf:input ref="ReadOnly"><xf:label>ReadOnly</xf:label></xf:input></p>
>   <p><xf:input ref="Required"><xf:label>Required</xf:label></xf:input></p>
>   <p><xf:input ref="Relevant"><xf:label>Relevant</xf:label></xf:input></p>
>   <p><xf:output 
> ref="Calculate"><xf:label>Calculate</xf:label></xf:output></p>
>   <p><xf:input 
> ref="Constraint"><xf:label>Constraint</xf:label></xf:input></p>
>   <p><xf:submit 
> submission="SaveLocal"><xf:label>Save</xf:label></xf:submit></p>
>  </body>
> </html>
> 
> for Mozilla drop the fp namespace, object and import
> for Novell drop the fp namespave, object and replace import with
>     <?import namespace="xf" urn="http://www.w3.org/2002/xforms" 
> implementation="#default#nxforms"/>
> 
> tried it with Mozilla, IE with formsPlayer plugin and IE with Novell plugin, 
> each give a different behaviour
> 
> formsPlayer plays the example completely correctly, but my intention was to 
> make a relevant rule for the Relevant field if Required was greater than 5
> and after half a day i gave up on that, no way to get it working
> 
> Novell only shows the save button and it works, but none of the fields is 
> displayed !!!
> 
> Mozilla shows fields but doesn't show any of the default values and any 
> values that you enter are not saved, but saving works with the initial 
> values !!!
> 
> is my form that bad ???
> i was very excited when i started learing about XForms (XForms essentials by 
> Dubinko)
> in theory everything seems great
> but implementation seems long way off for something that became a standard 
> 19 months ago !!!
> 
> i think it will probably go in the ijskast again, my chef will not tolerate 
> anymore time wasting :(
> 
> Alex 
> 
> 

Hi Alex,

Its takes a little bit to get the hang of writing XForms.  Did you try 
running your form through an XForms validator?  There is one at: 
http://xformsinstitute.com/validator/  When I put your form through the 
validator (the first step I always do when something isn't working the 
way that I think that it should) I got some errors.  Firstly, you need 
to namespace qualify the instance.  If you are using xpath expressions 
to get to the instance without namespaces, then you need to put xmlns="" 
on either the xf:instance node or on the root node of the instance 
document (the first child node of the xf:instance).  This is covered in 
the XForms:Essentials book, but you may have missed it when you were 
reading it.  "The instance data XML itself is not defined in any 
namespace, so the xmlns="" declaration is essential to turn off the 
default XHTML namespace that would otherwise be in effect at this 
point."  When I did that to your form, I got the numbers to appear.

Then I changed the value of 'required' to 43, saw the value change in 
the calculate when I tabbed out of the field and when I clicked on the 
save button it saved fine to my local disc.  When I changed the required 
field to 'aa' I saw calc go to NaN and save was NOT successful because 
the required field did not contain a valid integer.

I got what you need to make relevant do what you want it to do, too. 
Use this bind: <xf:bind id="Relevant" relevant="../Required &gt; 5" 
nodeset="Relevant" />.  Of course, to make it hide under Mozilla you'll 
have to style it.  We don't support pseudo classes quite yet, so you'd 
have to use the temporary attribute that we set on it.  So the style 
would look like this: xf|*[disabled] {display: none; }.  For Novell's 
plugin or formsPlayer, that should look like: xf|*:disabled {display: 
none; }, I believe.

I hope that this helps,
--Aaron
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.