Re: [Xsltforms-support] [xsltforms] Events not getting raised on subform element? (#8)
Brought to you by:
alain-couthures
|
From: Artyom S. <art...@gm...> - 2015-07-08 03:56:59
|
Hello Tim, 2015-07-07 19:31 GMT+06:00 Tim Thompson <tim...@gm...>: > Hi, Artyom, > > This might be a good question for the XSLTForms e-mail support list > (copied here). > Thanks for pointing this out. > From what I can tell, since your subform target is in a separate > <xf:case>, it is not possible to load the subforms a second time without > toggling the case again. If I add <xforms:toggle case="form-sub"/> to the > #form-main triggers, it seems to work as expected: > > <xforms:trigger> > <xforms:label>Open subform 1</xforms:label> > <xforms:action ev:event="DOMActivate"> > <xforms:message>Opening subform 1</xforms:message> > <xforms:toggle case="form-sub"/> > <xforms:load show="embed" targetid="subform" > resource="showform3_subform1.xml"/> > </xforms:action> > </xforms:trigger> > > Indeed, this works great! Thank you very much. I'm attaching the modified sample for completeness. Subform 1 will never load due to a non-existent resource (which is fully reported to the user). > -- > Tim A. Thompson > Metadata Librarian (Spanish/Portuguese Specialty) > Princeton University Library > > > On Tue, Jul 7, 2015 at 2:32 AM, Artyom Shalkhakov < > not...@gi...> wrote: > >> Hello, >> >> I have a form sketch where subforms are embedded into the main form. >> However, there are complications: >> >> 1. if subform failed to be found, then the user should be notified >> about the error >> 2. user has to be able to dismiss the subform either by accepting or >> rejecting it >> >> Here's the main form (showform3_load.xml): >> >> <?xml-stylesheet href="/xsltforms/xsltforms.xsl" type="text/xsl"?> >> <html xmlns="http://www.w3.org/1999/xhtml" >> xmlns:xforms="http://www.w3.org/2002/xforms" >> xmlns:ev="http://www.w3.org/2001/xml-events"> >> <head> >> <title>Main Form</title> >> <xforms:model> >> <xforms:instance> >> <data xmlns=""/> >> </xforms:instance> >> <!-- FIXME: these actions are only run once (probably get removed on subform unload?) --> >> <xforms:action ev:event="xforms-link-exception" ev:observer="subform"> >> <xforms:message> >> Failed to obtain the subform at: <xforms:output value="event('resource-uri')"/>, >> error code: <xforms:output value="event('response-status-code')"/>, >> error reason: <xforms:output value="event('response-reason-phrase')"/> >> </xforms:message> >> </xforms:action> >> <xforms:action ev:event="xforms-load-done" ev:observer="subform"> >> <xforms:message>Load Success!</xforms:message> >> <xforms:toggle case="form-sub"/> >> </xforms:action> >> </xforms:model> >> </head> >> <body> >> <xforms:switch id="form-switch"> >> <!-- this is the "main" form --> >> <xforms:case id="form-main"> >> <h2>Main form</h2> >> <xforms:trigger> >> <xforms:label>Open subform 1</xforms:label> >> <xforms:action ev:event="DOMActivate"> >> <xforms:message>Opening subform 1</xforms:message> >> <xforms:load show="embed" targetid="subform" resource="showform3_subform1.xml"/> >> </xforms:action> >> </xforms:trigger> >> <xforms:trigger> >> <xforms:label>Open subform 2</xforms:label> >> <xforms:action ev:event="DOMActivate"> >> <xforms:message>Opening subform 2</xforms:message> >> <xforms:load show="embed" targetid="subform" resource="showform3_subform2.xml"/> >> </xforms:action> >> </xforms:trigger> >> </xforms:case> >> <!-- this is the portion of the form that we will be using for subforms (e.g. Edit subform) --> >> <xforms:case id="form-sub"> >> <xforms:trigger> >> <xforms:label>Accept Subform</xforms:label> >> <xforms:action ev:event="DOMActivate"> >> <xforms:message>Accepting Subform</xforms:message> >> <xforms:unload targetid="subform"/> >> <xforms:toggle case="form-main"/> >> </xforms:action> >> </xforms:trigger> >> <!-- this actually does what we want, but the subform *by itself* >> is invalid (there is no such targetid in the subform! >> --> >> <xforms:trigger> >> <xforms:label>Reject Subform</xforms:label> >> <xforms:action ev:event="DOMActivate"> >> <xforms:message>Rejecting Subform</xforms:message> >> <xforms:unload targetid="subform"/> >> <xforms:toggle case="form-main"/> >> </xforms:action> >> </xforms:trigger> >> <xforms:group id="subform"/> >> </xforms:case> >> </xforms:switch> >> </body> >> </html> >> >> Here is subform 1 (showform3_subform1.xml): >> >> <?xml-stylesheet href="/xsltforms/xsltforms.xsl" type="text/xsl"?> >> <html xmlns="http://www.w3.org/1999/xhtml" >> xmlns:xforms="http://www.w3.org/2002/xforms" >> xmlns:ev="http://www.w3.org/2001/xml-events"> >> <head> >> <title>Subform 1</title> >> <xforms:model> >> <xforms:instance> >> <data xmlns=""/> >> </xforms:instance> >> </xforms:model> >> </head> >> <body> >> <h2>Subform 1</h2> >> <p>hello world!</p> >> </body> >> </html> >> >> And finally, here is subform 3 (showform3_subform2.xml): >> >> <?xml-stylesheet href="/xsltforms/xsltforms.xsl" type="text/xsl"?> >> <html xmlns="http://www.w3.org/1999/xhtml" >> xmlns:xforms="http://www.w3.org/2002/xforms" >> xmlns:ev="http://www.w3.org/2001/xml-events"> >> <head> >> <title>Subform 2</title> >> <xforms:model> >> <xforms:instance> >> <data xmlns=""/> >> </xforms:instance> >> </xforms:model> >> </head> >> <body> >> <h2>Subform 2</h2> >> <p>goodbye world!</p> >> </body> >> </html> >> >> To reproduce: >> >> 1. Open the main form >> 2. Click on "Open subform 1" >> 3. Subform 1 will be opened >> 4. Click on "Accept Subform" >> 5. You will be brought back to the main form >> 6. Click on either "Open subform 1" or "Open subform 2", and there is >> no change >> >> Please help me figure this one out. >> >> — >> Reply to this email directly or view it on GitHub >> <https://github.com/AlainCouthures/xsltforms/issues/8>. >> > > -- Cheers, Artyom Shalkhakov |