Need Help with insert trigger

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Need Help with insert trigger

JohnBampton
I only want to insert al tags and its children into the instance.  There will only ever be one item tag but there can be many al tags.  At the moment when I click add location trigger, the text in the insuredname field is deleted.  Does anyone know how to fix this?  Regards.


       
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:widget="http://orbeon.org/oxf/xml/widget" xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xbl="http://www.w3.org/ns/xbl"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner" lang="en">

        <xhtml:head>
        <xforms:model id="main-model">
            <xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified">
                                 <xs:element name="data">
                    <xs:complexType>                     
                        <xs:sequence>
                            <xs:element name="item" type="item"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
               
                <xs:complexType name="item">
                    <xs:sequence>
                        <xs:element name="insuredname" type="xs:string"/>
                        <xs:sequence minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="al" type="al"/> 
                        </xs:sequence>   
                    </xs:sequence>
                </xs:complexType>
                               
                <xs:complexType name="al">
                    <xs:sequence>
                    <xs:element name="name" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:schema>
       
            <xforms:instance id="data-instance">
                <data>
                <item>
                        <insuredname></insuredname>
                        <al>
                            <name></name>
                        </al>
                    </item>
                </data>
            </xforms:instance>
           
            <xforms:instance id="data-template">
                <item>
                    <insuredname></insuredname>
                    <al>
                        <name></name>
                    </al>
                </item>
            </xforms:instance>
        </xforms:model>
        </xhtml:head>
        <xhtml:body> 
            <xhtml:p>
                    <xforms:input id="insuredname" ref="item/insuredname" incremental="true" class="input"  navindex="1">
                        <xforms:label class="fixed-width">Insured Name</xforms:label>
                        <xforms:alert>Insured Name is required</xforms:alert>
                    </xforms:input>
            </xhtml:p>
            <xhtml:table>
            <xhtml:tr>
                    <xhtml:td>
                        <xforms:trigger appearance="minimal">
                            <xforms:label>Add additional location</xforms:label>
                            <xforms:insert ev:event="DOMActivate" context="instance('data-instance')" nodeset="data/item/al" at="1" position="before" origin="instance('data-template')"/>
                        </xforms:trigger>
                     
                    </xhtml:td>
                </xhtml:tr>
             
                <xforms:repeat nodeset="item/al" id="al-repeat">
                    <xhtml:tr>
                    <xhtml:td colspan="2">
                            <xforms:trigger appearance="minimal">
                                <xforms:delete ev:event="DOMActivate" context="instance('data-instance')" nodeset="item/al" at="index('al-repeat')"/>
                                <xforms:label>Delete</xforms:label>
                            </xforms:trigger>
                        </xhtml:td>
                     </xhtml:tr> 
                     <xhtml:tr>   
                        <xhtml:td>
                            <xforms:input id="alname" ref="name" incremental="true" class="input">   
                            <xforms:label class="fixed-width">Name</xforms:label>
                                <xforms:alert>Name is required</xforms:alert>
                    </xforms:input>
                        </xhtml:td>
                    </xhtml:tr>
            </xforms:repeat>
             </xhtml:table>
        </xhtml:body>
</xhtml:html>
Reply | Threaded
Open this post in threaded view
|

Re: Need Help with insert trigger

Alessandro Vernet
Administrator
John,

JohnBampton wrote
I only want to insert al tags and its children into the instance.  There will only ever be one item tag but there can be many al tags.  At the moment when I click add location trigger, the text in the insuredname field is deleted.  Does anyone know how to fix this?  Regards.
Then I guess you just want to insert a <al> element (with its <name>). So you'll need to change the data-template instance for that.

Alex
Reply | Threaded
Open this post in threaded view
|

Re: Need Help with insert trigger

JohnBampton
Hi Alessandro,

what do I change it to?  Please help me!

Regards,

John



Alessandro Vernet wrote
John,

JohnBampton wrote
I only want to insert al tags and its children into the instance.  There will only ever be one item tag but there can be many al tags.  At the moment when I click add location trigger, the text in the insuredname field is deleted.  Does anyone know how to fix this?  Regards.
Then I guess you just want to insert a <al> element (with its <name>). So you'll need to change the data-template instance for that.

Alex
Reply | Threaded
Open this post in threaded view
|

Re: Need Help with insert trigger

Colin Berry
In reply to this post by JohnBampton
Try this...

JohnBampton wrote
I only want to insert al tags and its children into the instance.  There will only ever be one item tag but there can be many al tags.  At the moment when I click add location trigger, the text in the insuredname field is deleted.  Does anyone know how to fix this?  Regards.


       
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:widget="http://orbeon.org/oxf/xml/widget" xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xbl="http://www.w3.org/ns/xbl"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner" lang="en">

        <xhtml:head>
        <xforms:model id="main-model">
            <xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified">
                                 <xs:element name="data">
                    <xs:complexType>                     
                        <xs:sequence>
                            <xs:element name="item" type="item"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
               
                <xs:complexType name="item">
                    <xs:sequence>
                        <xs:element name="insuredname" type="xs:string"/>
                        <xs:sequence minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="al" type="al"/> 
                        </xs:sequence>   
                    </xs:sequence>
                </xs:complexType>
                               
                <xs:complexType name="al">
                    <xs:sequence>
                    <xs:element name="name" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:schema>
       
            <xforms:instance id="data-instance">
                <data>
                <item>
                        <insuredname></insuredname>
                        <al>
                            <name></name>
                        </al>
                    </item>
                </data>
            </xforms:instance>
           
            <xforms:instance id="data-template">
                <item>
                    <insuredname></insuredname>
                    <al>
                        <name></name>
                    </al>
                </item>
            </xforms:instance>
        </xforms:model>
        </xhtml:head>
        <xhtml:body> 
            <xhtml:p>
                    <xforms:input id="insuredname" ref="item/insuredname" incremental="true" class="input"  navindex="1">
                        <xforms:label class="fixed-width">Insured Name</xforms:label>
                        <xforms:alert>Insured Name is required</xforms:alert>
                    </xforms:input>
            </xhtml:p>
            <xhtml:table>
            <xhtml:tr>
                    <xhtml:td>
                        <xforms:trigger appearance="minimal">
                            <xforms:label>Add additional location</xforms:label>


                           

<xforms:insert ev:event="DOMActivate" context="instance('data-instance')" nodeset="data/item/al" at="1" position="before" origin="instance('data-template')/al/name"/>
                        </xforms:trigger>
                     
                    </xhtml:td>
                </xhtml:tr>
             
                <xforms:repeat nodeset="item/al" id="al-repeat">
                    <xhtml:tr>
                    <xhtml:td colspan="2">
                            <xforms:trigger appearance="minimal">
                                <xforms:delete ev:event="DOMActivate" context="instance('data-instance')" nodeset="item/al" at="index('al-repeat')"/>
                                <xforms:label>Delete</xforms:label>
                            </xforms:trigger>
                        </xhtml:td>
                     </xhtml:tr> 
                     <xhtml:tr>   
                        <xhtml:td>


                               
<xforms:input id="alname" ref="instance('data-template')/name" incremental="true" class="input">   
                            <xforms:label class="fixed-width">Name</xforms:label>
                                <xforms:alert>Name is required</xforms:alert>
                    </xforms:input>
                        </xhtml:td>
                    </xhtml:tr>
            </xforms:repeat>
             </xhtml:table>
        </xhtml:body>
</xhtml:html>
Reply | Threaded
Open this post in threaded view
|

Re: Need Help with insert trigger

JohnBampton
Hi Colin, that doesn't work.  Thanks anyway.

Regards,

John.


Colin Berry wrote
Try this...

JohnBampton wrote
I only want to insert al tags and its children into the instance.  There will only ever be one item tag but there can be many al tags.  At the moment when I click add location trigger, the text in the insuredname field is deleted.  Does anyone know how to fix this?  Regards.


       
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:widget="http://orbeon.org/oxf/xml/widget" xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xbl="http://www.w3.org/ns/xbl"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner" lang="en">

        <xhtml:head>
        <xforms:model id="main-model">
            <xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified">
                                 <xs:element name="data">
                    <xs:complexType>                     
                        <xs:sequence>
                            <xs:element name="item" type="item"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
               
                <xs:complexType name="item">
                    <xs:sequence>
                        <xs:element name="insuredname" type="xs:string"/>
                        <xs:sequence minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="al" type="al"/> 
                        </xs:sequence>   
                    </xs:sequence>
                </xs:complexType>
                               
                <xs:complexType name="al">
                    <xs:sequence>
                    <xs:element name="name" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:schema>
       
            <xforms:instance id="data-instance">
                <data>
                <item>
                        <insuredname></insuredname>
                        <al>
                            <name></name>
                        </al>
                    </item>
                </data>
            </xforms:instance>
           
            <xforms:instance id="data-template">
                <item>
                    <insuredname></insuredname>
                    <al>
                        <name></name>
                    </al>
                </item>
            </xforms:instance>
        </xforms:model>
        </xhtml:head>
        <xhtml:body> 
            <xhtml:p>
                    <xforms:input id="insuredname" ref="item/insuredname" incremental="true" class="input"  navindex="1">
                        <xforms:label class="fixed-width">Insured Name</xforms:label>
                        <xforms:alert>Insured Name is required</xforms:alert>
                    </xforms:input>
            </xhtml:p>
            <xhtml:table>
            <xhtml:tr>
                    <xhtml:td>
                        <xforms:trigger appearance="minimal">
                            <xforms:label>Add additional location</xforms:label>


                           

<xforms:insert ev:event="DOMActivate" context="instance('data-instance')" nodeset="data/item/al" at="1" position="before" origin="instance('data-template')/al/name"/>
                        </xforms:trigger>
                     
                    </xhtml:td>
                </xhtml:tr>
             
                <xforms:repeat nodeset="item/al" id="al-repeat">
                    <xhtml:tr>
                    <xhtml:td colspan="2">
                            <xforms:trigger appearance="minimal">
                                <xforms:delete ev:event="DOMActivate" context="instance('data-instance')" nodeset="item/al" at="index('al-repeat')"/>
                                <xforms:label>Delete</xforms:label>
                            </xforms:trigger>
                        </xhtml:td>
                     </xhtml:tr> 
                     <xhtml:tr>   
                        <xhtml:td>


                               
<xforms:input id="alname" ref="instance('data-template')/name" incremental="true" class="input">   
                            <xforms:label class="fixed-width">Name</xforms:label>
                                <xforms:alert>Name is required</xforms:alert>
                    </xforms:input>
                        </xhtml:td>
                    </xhtml:tr>
            </xforms:repeat>
             </xhtml:table>
        </xhtml:body>
</xhtml:html>
Reply | Threaded
Open this post in threaded view
|

Re: Need Help with insert trigger

JohnBampton
In reply to this post by JohnBampton
It seems that no one can help me!??

I am now thinking that orbeon forms is not suitable for my needs as it cannot seem to deal with nested  models...


JohnBampton wrote
I only want to insert al tags and its children into the instance.  There will only ever be one item tag but there can be many al tags.  At the moment when I click add location trigger, the text in the insuredname field is deleted.  Does anyone know how to fix this?  Regards.


       
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:widget="http://orbeon.org/oxf/xml/widget" xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xbl="http://www.w3.org/ns/xbl"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner" lang="en">

        <xhtml:head>
        <xforms:model id="main-model">
            <xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified">
                                 <xs:element name="data">
                    <xs:complexType>                     
                        <xs:sequence>
                            <xs:element name="item" type="item"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
               
                <xs:complexType name="item">
                    <xs:sequence>
                        <xs:element name="insuredname" type="xs:string"/>
                        <xs:sequence minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="al" type="al"/> 
                        </xs:sequence>   
                    </xs:sequence>
                </xs:complexType>
                               
                <xs:complexType name="al">
                    <xs:sequence>
                    <xs:element name="name" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:schema>
       
            <xforms:instance id="data-instance">
                <data>
                <item>
                        <insuredname></insuredname>
                        <al>
                            <name></name>
                        </al>
                    </item>
                </data>
            </xforms:instance>
           
            <xforms:instance id="data-template">
                <item>
                    <insuredname></insuredname>
                    <al>
                        <name></name>
                    </al>
                </item>
            </xforms:instance>
        </xforms:model>
        </xhtml:head>
        <xhtml:body> 
            <xhtml:p>
                    <xforms:input id="insuredname" ref="item/insuredname" incremental="true" class="input"  navindex="1">
                        <xforms:label class="fixed-width">Insured Name</xforms:label>
                        <xforms:alert>Insured Name is required</xforms:alert>
                    </xforms:input>
            </xhtml:p>
            <xhtml:table>
            <xhtml:tr>
                    <xhtml:td>
                        <xforms:trigger appearance="minimal">
                            <xforms:label>Add additional location</xforms:label>
                            <xforms:insert ev:event="DOMActivate" context="instance('data-instance')" nodeset="data/item/al" at="1" position="before" origin="instance('data-template')"/>
                        </xforms:trigger>
                     
                    </xhtml:td>
                </xhtml:tr>
             
                <xforms:repeat nodeset="item/al" id="al-repeat">
                    <xhtml:tr>
                    <xhtml:td colspan="2">
                            <xforms:trigger appearance="minimal">
                                <xforms:delete ev:event="DOMActivate" context="instance('data-instance')" nodeset="item/al" at="index('al-repeat')"/>
                                <xforms:label>Delete</xforms:label>
                            </xforms:trigger>
                        </xhtml:td>
                     </xhtml:tr> 
                     <xhtml:tr>   
                        <xhtml:td>
                            <xforms:input id="alname" ref="name" incremental="true" class="input">   
                            <xforms:label class="fixed-width">Name</xforms:label>
                                <xforms:alert>Name is required</xforms:alert>
                    </xforms:input>
                        </xhtml:td>
                    </xhtml:tr>
            </xforms:repeat>
             </xhtml:table>
        </xhtml:body>
</xhtml:html>
Reply | Threaded
Open this post in threaded view
|

Re: Need Help with insert trigger

Alessandro Vernet
Administrator
John,

JohnBampton wrote
It seems that no one can help me!??
Try the following: http://pastie.org/578214

Alex
Reply | Threaded
Open this post in threaded view
|

Re: Need Help with insert trigger

JohnBampton
Thanks Alex,

that works,

Thanks a lot.


Alessandro Vernet wrote
John,

JohnBampton wrote
It seems that no one can help me!??
Try the following: http://pastie.org/578214

Alex
Reply | Threaded
Open this post in threaded view
|

Re: Need Help with insert trigger

Alessandro Vernet
Administrator
John,

JohnBampton wrote
Thanks Alex,
that works,
Excellent; I am glad this worked for you. The way <xforms:insert> works is not immediately obvious. It is a very powerful construct, and I think it is well worth investing some time to fully grasp all the things you can do with <xforms:insert>.

Alex