Hello Tim,

2015-07-07 19:31 GMT+06:00 Tim Thompson <[email protected]>:

> 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 <
> [email protected]> 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
<?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";
      xmlns:xsltforms="http://www.agencexml.com/xsltforms";
      xmlns:rte="http://www.agencexml.com/xsltforms/rte";>
  <head>
    <title>Main Form</title>
    <xforms:model>
      <xforms:instance>
        <data xmlns=""/>
      </xforms:instance>
      <schema xmlns="http://www.w3.org/2001/XMLSchema"; targetNamespace="http://www.agencexml.com/xsltforms/rte";>
        <simpleType name="standardHTML">
          <restriction base="xforms:HTMLFragment" xsltforms:rte="TinyMCE"/>
          <annotation>
            <appinfo>
              {
              plugins: [
              "advlist autolink lists link image charmap print preview anchor",
              "searchreplace visualblocks code fullscreen",
              "insertdatetime media table contextmenu paste"
              ],
              toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
              }
            </appinfo>
          </annotation>
        </simpleType>
      </schema>
      <xforms:instance id="subform-data">
        <data xmlns="">
          <subform/>
        </data>
      </xforms:instance>
      <!-- this instance is only for subforms -->
      <xforms:bind id="subform-data-bind" nodeset="instance('subform-data')" type="rte:standardHTML"/>
      
      <!-- another idea: obtain the subform via submit;
      then use "load" to embed the subform where it stands
      -->

      <xforms:submission id="open-subform" replace="instance" targetref="instance('subform-data')/*" method="get">
        <!-- NOTE: full path to the resource! -->
        <xforms:resource value="concat('/', 'tests/showform3_subform.xml')"/>
        <xforms:action ev:event="xforms-submit-error">
          <xforms:message>Failed to obtain the subform!</xforms:message>
          <xforms:toggle case="form-sub-error"/>
        </xforms:action>
        <xforms:action ev:event="xforms-submit-done">
          <xforms:message>
            <xforms:output value="serialize(instance('subform-data'))"/>
          </xforms:message>
          <!-- note: this will just unhelpfully open the HTML without the tags in the current window... -->
          <xforms:load show="embed" targetid="subform" bind="subform-data-bind"/>
          <xforms:toggle case="form-sub"/>
        </xforms:action>
      </xforms:submission>      
    </xforms:model>
  </head>
  <body>
    <!--
    how do we hide the main form to show ONLY the subform?
    - when the subform is rejected or accepted, we want to revert the view
    - using a group?
    -->
    <xforms:switch id="form-switch">
      <!-- this is the "main" form -->
      <xforms:case id="form-main">
        <xforms:submit submission="open-subform">
          <xforms:label>Show Subform</xforms:label>
        </xforms:submit>
            <!--
        what if loading fails? if it does, we want to show a message but DON'T activate the subform!

replace toggle with:
<toggle ev:event="xforms-load-done" ev:observer="change"/>
where "change" is the id of the submission element
and xforms-load-done is some made-up event that is similar to xforms-submit-done

NOTE: if @resource is not found, xforms-link-exception is raised
NOTE: xforms-load-done actually exists!

issueLoadException_()
event('error-type') = 'resource-error'
xforms-load-done
- seems to be raised even when in error
xforms-load-error
        -->
      </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">
        <!-- TODO: only relevant if subform is active -->
        <xforms:group id="subform"/>
      </xforms:case>
      <!-- this should show some data about the errors; OR, we could also show this case for when data is being fetched -->
      <xforms:case id="form-sub-error">
        <p>Error!</p>
        <!--
        <xforms:output value="concat(event('method'), ';' event('resource-uri'), ';', event('error-type'))"/>
        -->
      </xforms:case>
    </xforms:switch>
  </body>
</html>
<?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>
<?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>
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Xsltforms-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xsltforms-support

Reply via email to