Thread: [Xsltforms-support] xf:reset does not restore xf:itemset items modified by xf:submission
Brought to you by:
alain-couthures
From: Kostis A. <ank...@gm...> - 2010-03-30 14:40:49
Attachments:
items.xml
resetItemset.xml
|
Hi, Reseting a model does not restore a modified-by-submission xf:itemsets. Reset indeed works when itemset was modified by an xf:delete (xf:insert??) action. Reported against rev372, Chrome, Firefox. The following files demonstrate the problem. XForms file ---------------- <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="xsltforms/xsltforms.xsl" encoding="UTF-8" type="text/xsl"?> <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.w3.org/2002/xforms http://www.w3.org/MarkUp/Forms/2007/XForms-11-Schema.xsd http://www.w3.org/2001/xml-events http://www.w3.org/MarkUp/SCHEMA/xml-events-attribs-1.xsd "> <head> <title>Restore xf:itemsets on xf:reset</title> <xf:model id="model-main" > <xf:instance id="inst-main"> <main> <data >1</data> </main> </xf:instance> <xf:instance id="inst-items" > <items> <item>1</item> <item>2</item> <item>3</item> </items> </xf:instance> <xf:bind id="bind-data" nodeset="/main/data" /> <xf:submission id="sub-fetch-items" resource="items.xml" method="GET" replace="instance" instance="inst-items" > </xf:submission> </xf:model> </head> <body> <p>Data: <xf:output ref="/main/data"/> </p> <p>xf:itemset's bound-document contents: <xf:repeat nodeset="instance('inst-items')/item"> <xf:output ref="."/> </xf:repeat> </p> Select1(minimal): <xf:select1 ref="/main/data"> <xf:itemset nodeset="instance('inst-items')/item"> <xf:label ref="." /> <xf:value ref="." /> </xf:itemset> </xf:select1> Select1(full): <xf:select1 ref="/main/data" appearance="full"> <xf:itemset nodeset="instance('inst-items')/item"> <xf:label ref="." /> <xf:value ref="." /> </xf:itemset> </xf:select1> Select(minimal): <xf:select ref="/main/data"> <xf:itemset nodeset="instance('inst-items')/item"> <xf:label ref="." /> <xf:value ref="." /> </xf:itemset> </xf:select> <xf:trigger> <xf:label>Load items from file</xf:label> <xf:action ev:event="DOMActivate" > <xf:send submission="sub-fetch-items"/> </xf:action> </xf:trigger> <xf:trigger> <xf:label>Delete bound xf:itemset nodes</xf:label> <xf:action ev:event="DOMActivate" > <xf:delete nodeset="instance('inst-items')/*"/> </xf:action> </xf:trigger> <xf:trigger> <xf:label>Reset restores only xf:delete effects</xf:label> <xf:action ev:event="DOMActivate" > <xf:reset/> </xf:action> </xf:trigger> </body> </html> Items file ------------- <items> <item>3</item> </items> |
From: Kostis A. <ank...@gm...> - 2010-04-22 18:59:09
Attachments:
preserveOldDocsOnReplaceInstance.diff
|
Hi, i fixed this bug. So now <xf:reset> works as by the xforms specs, and restores instance-documents to their original contents on.submissions with: replace="instance" The following patch against rev397 modifies just 3-lines : http://pastebin.com/vWM6w1sN You can use the test-xform i had submitted on this thread to check the patch indeed fixed the bug. PATCH DESCRIPTION ------------------ I added a 'isPreserveOld' argument to XFInstance.setDoc() that when it is 'true it skips XFinstrance.store() altogether. This new argument is 'true' only when invoking from submissions with: replace="instance" Regards, Kostis On Tue, Mar 30, 2010 at 5:40 PM, Kostis Anagnostopoulos <ank...@gm...> wrote: > Hi, > > Reseting a model does not restore a modified-by-submission xf:itemsets. > Reset indeed works when itemset was modified by an xf:delete > (xf:insert??) action. > > Reported against rev372, Chrome, Firefox. > > > The following files demonstrate the problem. > > XForms file > ---------------- > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet href="xsltforms/xsltforms.xsl" encoding="UTF-8" > type="text/xsl"?> > <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" > xmlns:xf="http://www.w3.org/2002/xforms" > xmlns:ev="http://www.w3.org/2001/xml-events" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=" > http://www.w3.org/2002/xforms > http://www.w3.org/MarkUp/Forms/2007/XForms-11-Schema.xsd > http://www.w3.org/2001/xml-events > http://www.w3.org/MarkUp/SCHEMA/xml-events-attribs-1.xsd > "> > <head> > <title>Restore xf:itemsets on xf:reset</title> > <xf:model id="model-main" > > <xf:instance id="inst-main"> > <main> > <data >1</data> > </main> > </xf:instance> > <xf:instance id="inst-items" > > <items> > <item>1</item> > <item>2</item> > <item>3</item> > </items> > </xf:instance> > > <xf:bind id="bind-data" nodeset="/main/data" /> > > <xf:submission id="sub-fetch-items" resource="items.xml" method="GET" > replace="instance" instance="inst-items" > > > </xf:submission> > </xf:model> > </head> > > <body> > <p>Data: <xf:output ref="/main/data"/> </p> > <p>xf:itemset's bound-document contents: > <xf:repeat nodeset="instance('inst-items')/item"> > <xf:output ref="."/> > </xf:repeat> > </p> > Select1(minimal): <xf:select1 ref="/main/data"> > <xf:itemset nodeset="instance('inst-items')/item"> > <xf:label ref="." /> > <xf:value ref="." /> > </xf:itemset> > </xf:select1> > Select1(full): <xf:select1 ref="/main/data" appearance="full"> > <xf:itemset nodeset="instance('inst-items')/item"> > <xf:label ref="." /> > <xf:value ref="." /> > </xf:itemset> > </xf:select1> > > Select(minimal): <xf:select ref="/main/data"> > <xf:itemset nodeset="instance('inst-items')/item"> > <xf:label ref="." /> > <xf:value ref="." /> > </xf:itemset> > </xf:select> > > <xf:trigger> > <xf:label>Load items from file</xf:label> > <xf:action ev:event="DOMActivate" > > <xf:send submission="sub-fetch-items"/> > </xf:action> > </xf:trigger> > <xf:trigger> > <xf:label>Delete bound xf:itemset nodes</xf:label> > <xf:action ev:event="DOMActivate" > > <xf:delete nodeset="instance('inst-items')/*"/> > </xf:action> > </xf:trigger> > > <xf:trigger> > <xf:label>Reset restores only xf:delete effects</xf:label> > <xf:action ev:event="DOMActivate" > > <xf:reset/> > </xf:action> > </xf:trigger> > > </body> > </html> > > Items file > ------------- > <items> > <item>3</item> > </items> > |