Closed
Bug 278471
Opened 20 years ago
Closed 20 years ago
reset event on Model element doesn't work
Categories
(Core Graveyard :: XForms, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: aaronr, Assigned: aaronr)
References
Details
Attachments
(2 files, 3 obsolete files)
1.60 KB,
application/xhtml+xml
|
Details | |
11.28 KB,
patch
|
bryner
:
superreview+
|
Details | Diff | Splinter Review |
The model element doesn't currently handle the xforms-reset event. I will attach a testcase that shows the problem. We need to be sure to take into account when we are using external instance data, too. Not just as simple as re-populating the instance documents with the instance elements in the DOM :) Can't just read in again from the external source file since it may have changed from underneath us. Actually that is a good compatibility testcase to make sure we behave like the other implementations...do they handle reset correctly or do they "reinitialize"? And MDG will probably have to be notified in some way since the data will change and even potentially the data type of the data.
Comment 2•20 years ago
|
||
from section 4.3.8 of the xforms spec: The default action for this event results in the following: The instance data is reset to the tree structure and values it had immediately after having processed the xforms-ready event. Then, the events xforms-rebuild, xforms-recalculate, xforms-revalidate and xforms-refresh are dispatched to the model element in sequence. I agree that we probably don't want to rely on being able to reload the same instance data. In fact, it is entirely possible that the instance data may have been modified by a submission. It's also possible that inline instance data may have been modified via the DOM, however unlikely, so reloading inline instance data from the DOM is also probably not right. I think this means that we need to keep a copy of the original instance data in memory, which is just plain unfortunate. It's too bad the XForms spec didn't say that the instance data will be reset from source or something like that :-/
other testcase shows another XForms bug dealing with delaying actions inside an xforms:action element. This new testcase only does set value and reset.
Attachment #171309 -
Attachment is obsolete: true
Nobody could come up with a better, fool-proof idea than just keeping an original copy of every instance document in memory, so that is what I did. On xforms-ready I backup the model's instance data, instance element by instance element. On xforms-reset, I restore the model's original instance data, instance element by instance element. What sux here is that instance data could be potentially very large, especially when loaded externally. We eventually need a better idea. But whatever it is, needs to restore instance data properly, even when data is monkied with by script.
Attachment #172419 -
Flags: review?(smaug)
Comment 5•20 years ago
|
||
(In reply to comment #4) > Created an attachment (id=172419) [edit] > proposed fix <stream-of-consciousness> nsXFormsModel::Rebuild() is still a NOOP. We need to reattach all elements, which is something like running ProcessBind() and doing a nsIXFormsControl::Bind() on all controls, or something in that direction, or the likes. </stream-of-consciousness>
Comment 6•20 years ago
|
||
Comment on attachment 172419 [details] [diff] [review] proposed fix >+ if(mDocument && mOriginalDocument) { >+ nsCOMPtr<nsIDOMNode> newNode, instanceRootNode; >+ nsCOMPtr<nsIDOMElement> instanceRoot; >+ rv = mDocument->GetDocumentElement(getter_AddRefs(instanceRoot)); >+ NS_ENSURE_SUCCESS(rv, rv); >+ NS_ENSURE_TRUE(instanceRoot, NS_ERROR_FAILURE); >+ instanceRootNode = do_QueryInterface(instanceRoot); instanceRoot is already an nsIDOMNode. >+ >+ nsCOMPtr<nsIDOMNode> nodeReturn; >+ rv = instanceRootNode->CloneNode(PR_TRUE, getter_AddRefs(newNode)); >+ if(NS_SUCCEEDED(rv)) { There should a mOriginalDocument->Import() here, but Mozilla is a bit buggy... >+ rv = mOriginalDocument->AppendChild(newNode, getter_AddRefs(nodeReturn)); >+ NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), And then Allan's comments. Make sure the nsXFormsModelElement::Rebuild() does the right thing. With this patch I get the following warning: WARNING: XForms: There are loops in the MDG , file nsXFormsMDGEngine.cpp, line 516
Attachment #172419 -
Flags: review?(smaug) → review-
Ok, I'll fix the patch about instanceRoot. I'd say that rebuild not working is a seperate bug, which I've opened -> https://bugzilla.mozilla.org/show_bug.cgi?id=279957. As far as xforms-reset handling, this bug is calling the right things in the right order. beaufour says that getting Rebuild() to work right will get rid of the warning that you mentioned.
removed instanceRootNode.
Attachment #172419 -
Attachment is obsolete: true
Attachment #172531 -
Flags: review?(smaug)
Comment 9•20 years ago
|
||
Comment on attachment 172531 [details] [diff] [review] fix with smaug's decision This looks ok, but Bug 279957 should probably be fixed before check in this one.
Attachment #172531 -
Flags: review?(smaug) → review+
Assignee | ||
Comment 10•20 years ago
|
||
same patch, just updated to the trunk.
Attachment #172531 -
Attachment is obsolete: true
Attachment #173011 -
Flags: superreview?(bryner)
Updated•20 years ago
|
Attachment #173011 -
Flags: superreview?(bryner) → superreview+
Comment 11•20 years ago
|
||
checked in
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Updated•8 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•