What have I done to break xForms?

I am learning xForms but apparently not well enough because I cannot figure out why this code is not working.

It parses in FF2 with xForms extension but does not render form controls. IE7 and X-Smiles give me different problems, but I'm not sure if these problems are due to my xForms or something else - until I get it working in FF2 I can't tell.

0


source to share


4 answers


This document contains a lot of problems, unfortunately I will go through each of them in turn.

1) The biggest problem comes up multiple times and seems to be related to some confusion between model

and UI. The two are completely separate animals in XForms that adhere to the controller-view-model design pattern. Therefore, you need to remember that everything is model

completely separate from everything in the user interface. The connection between the two is that UI controls can communicate with instance data nodes in your model

s. In practice, from the point of view of your document, it means that your elements select1

and repeat

should not be a child model

. Only instance

, bind

and action elements can be child elements model

.

2) You are using multiple elements model

that are not needed in such a simple form (since each model

can contain many instance

and bind

s). The reason I point this out is because you are introducing a couple of potential mistakes using multiple model

s, which are best avoided, sticking with one if possible model

. For example, the instance

XPath function will not work across model

s, so you have to be very careful about data dependencies between them. In addition, the UI control is updated to be model

bound, which has often given me problems in the past where controls did not appear to update safely.

3) Have you tried using an element repeat

to apply a child bind

to many nodes. This is incorrect because it repeat

is a user interface element and not a model element. However, since it bind

takes an attribute nodeset

instead of an attribute ref

, you don't need it at all repeat

. Instead, you can simply do this:

<xf:bind nodeset="//want" readonly="true()" />

      



4) On many UI controls, you specify bind attribute and ref attribute. These attributes are mutually exclusive as they represent different ways of achieving the same thing. The ref attribute must contain an XPath that identifies the data of the node instance to which you want to bind the UI control. The bind attribute must contain the id of the bound element that was defined elsewhere (the bind element itself will identify the node that the control is binding in this case via its nodeet attribute). So using both attributes in the same UI control is contradicting yourself.

5) In some places, you tried to use the ref attribute to bind a control to another element in the UI. Controls can only bind to instance data.

6) You have setvalue

inside a repeat

that you are trying to call in an event xforms-value-changed

. This event is not dispatched to the element repeat

, so yours setvalue

will never be called. The event xforms-value-changed

is only dispatched to main form controls that are defined in the XForms spec as:

Introduced | secret | TextArea | Exit | Loading | Range | trigger | send | choose | select1

7). Another answer to this question indicates that you are wrong to put your elements model

in the body of the document. Unfortunately I don't have enough reputation to comment there, but I just wanted to point out that the answer is actually wrong. While it was common practice to place elements model

in a document head

, nothing in the XForms specification provides for this. In fact, one major XForms processor, Ubiquity XForms , actually claims to model

be in the document body

due to browser restrictions.

+2


source


You should not place your models in the body section. Instead, all model definitions should be in a chapter section. As it is now, your code is not standard and very difficult to understand.



The Xforms Wiki book is a good resource for learning XForms.

0


source


I'll add that xf: repeat, xf: group, xf: input, ... cannot be children of xf: model

0


source


The XForms validator can be a good place to start . Afterwards, I recommend starting with a working example and gradually adding code to see which part doesn't work.

0


source







All Articles