Open ebruchez opened 11 years ago
How things work now:
ConcreteBinding
has ref to AbstractBinding
(this is still ok)ComponentControl
has ref to ConcreteBinding
, retrieved from partAnalysis.xblBindings
ComponentControl
is able to update the binding, BUT this is prevented at the top-level, because:Scope
and indexes objectsSince the top-level part is shareable, something has to change, and this is probably the hardest part (caching!).
One possible approach:
PartAnalysisImpl
for each top-level component with dynamic bindingBased on the above, the difficulty seems now to be how to handle the static state for those XBL controls which depend on the datatype.
Since the above was written, ComponentControl
has a hasLazyBinding
option, which currently only works for nested parts (i.e. Form Builder) which are specifically annotated. See #3477.
How hard would it be to change this condition to add this?
|| (part.isTopLevel && hasTypeBinding)
In addition, AbstractBinding
is still not lazy, and it should be. Further, it shouldn't be stored in the part, as discussed above, since the part is shared.
In short, not only ConcreteBinding
but also AbstractBinding
cannot be determined during static analysis, and they cannot be stored directly into ComponentControl
. We still need an indirection there.
Reviewing the above, that makes sense. Right now we associate an AbstractBinding
directly in XFormsAnnotator
as an IndexableBinding
. When we build the component tree, we create a ComponentControl
based on that.
The indirection we need here is something that says "here is an element whose actual binding may depend on a type that we don't yet know". For example xf:input
might have it's plain, string
implementation (which would also need to be done in XBL, which would be fine probably), or its fr:date
, fr:number
, etc. implementation.
So instead of storing a IndexableBinding
, maybe an ADT with EagerIndexableBinding | LazyIndexableBinding
.
At some point, either statically (case of bind
which is known before static analysis is complete) or dynamically (case where things are more dynamic), we can resolve the binding to a concrete AbstractBinding
. As a first step, we could only address the static approach. This is easier as it means that at the end of the static analysis, we have a resolved binding and that can stay in the shared PartAnalysis
.
As a second step, we can do the dynamic part.
This would solve a number of issues. For example, we would like to use a control layout compatible with Bootstrap to help with CSS styling. We can hardcode, but that's not so nice, and then the JavaScript client must be modified to recreate the inputs. That's changes in two places.
Two implement this, we need:
xf:*
elements (right now, only elements not in the XForms ns are supported)xforms|type
pseudo-class, and/or plain classes (right now format only supports matching on element QName)see how Noscript mode is impactedxforms|type
)We already support updating a shadow tree dynamically within
xxf:dynamic
. This was implemented to updatefr:section
in Form Builder.See also #1248.