Added action in Repeatable grid is not working for another grid iteration?

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

Added action in Repeatable grid is not working for another grid iteration?

vikash kumar
repeatable-grid-action.html

Hi,

In repeatable grid , I have added action for radio button. Based on selection i am hiding some fields and populating empty value to hidden fields. Except 1st grid iteration , this functionality is not working .

Please have a look of code that is in attachment.

Please let me know where i went wrong or Orbeon form screenshotany alternative approach to achieve this functionality.
Reply | Threaded
Open this post in threaded view
|

Re: Added action in Repeatable grid is not working for another grid iteration?

Alessandro  Vernet
Administrator
Hi Vikash,

What version of Orbeon Forms are you using? I am asking as the proper control resolution for action triggered by an action inside a repeat was implemented in 4.5 (https://github.com/orbeon/orbeon-forms/issues/1527).

If you're using 4.5 or newer, would you be able to share with us an example that calls a service, so we can reproduce the issue? If you need the URL of a public "service" that returns XML, you can do a GET on http://httpbin.org/xml.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Added action in Repeatable grid is not working for another grid iteration?

vikash kumar
Hi Alessandro,

We are using latest version of Orbeon .

<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:ev="http://www.w3.org/2001/xml-events"
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
         xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
         xmlns:exf="http://www.exforms.org/exf/1-0"
         xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
         xmlns:saxon="http://saxon.sf.net/"
         xmlns:sql="http://orbeon.org/oxf/xml/sql"
         xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
         xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
    <xh:head>
        <xh:title>Untitled Form</xh:title>
        <xf:model id="fr-form-model" xxf:expose-xpath-types="true">

           
            <xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all">
                <form>
                    <section-1>
                        <repeatable-grid>
                            <repeatable-grid-iteration>
                                <select-repeatable-radio-button>1</select-repeatable-radio-button>
                                <credit-card-number/>
                                <credit-card-name/>
                                <ach-number/>
                                <ach-name/>
                            </repeatable-grid-iteration>
                        </repeatable-grid>
                       
                    </section-1>
                </form>
            </xf:instance>

           
            <xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
                <xf:bind id="section-1-bind" name="section-1" ref="section-1">
                    <xf:bind id="repeatable-grid-bind" ref="repeatable-grid" name="repeatable-grid">
                        <xf:bind id="repeatable-grid-iteration-bind" ref="repeatable-grid-iteration"
                                 name="repeatable-grid-iteration">
                            <xf:bind id="select-repeatable-radio-button-bind" ref="select-repeatable-radio-button"
                                     name="select-repeatable-radio-button"/>
                            <xf:bind id="credit-card-number-bind" ref="credit-card-number" name="credit-card-number"
                                     relevant="$select-repeatable-radio-button=&#34;1&#34;"/>
                            <xf:bind id="credit-card-name-bind" ref="credit-card-name" name="credit-card-name"
                                     relevant="$select-repeatable-radio-button=&#34;1&#34;"/>
                            <xf:bind id="ach-number-bind" ref="ach-number" name="ach-number"
                                     relevant="$select-repeatable-radio-button=&#34;2&#34;"/>
                            <xf:bind id="ach-name-bind" ref="ach-name" name="ach-name"
                                     relevant="$select-repeatable-radio-button=&#34;2&#34;"/>
                        </xf:bind>
                    </xf:bind>
                   
                </xf:bind>
            </xf:bind>

           
            <xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
                <metadata>
                    <application-name>Repeatable_Selection</application-name>
                    <form-name>repeatable_selection</form-name>
                    <title xml:lang="en">Untitled Form</title>
                    <description xml:lang="en"/>
                    <singleton>false</singleton>
                </metadata>
            </xf:instance>

           
            <xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
                <attachments>
                    <css mediatype="text/css" filename="" size=""/>
                    <pdf mediatype="application/pdf" filename="" size=""/>
                </attachments>
            </xf:instance>

           
           
            <xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
                <resources>
                    <resource xml:lang="en">
                        <select-repeatable-radio-button>
                            <label/>
                            <hint/>
                            <item>
                                <label>Credit Card</label>
                                <hint/>
                                <value>1</value>
                            </item>
                            <item>
                                <label>ACH</label>
                                <hint/>
                                <value>2</value>
                            </item>
                        </select-repeatable-radio-button>
                        <credit-card-number>
                            <label>Credit Card Number</label>
                            <hint/>
                        </credit-card-number>
                        <credit-card-name>
                            <label>Name On Credit Card</label>
                            <hint/>
                        </credit-card-name>
                        <ach-number>
                            <label>ACH Number</label>
                            <hint/>
                        </ach-number>
                        <ach-name>
                            <label>Name On ACH Account</label>
                            <hint/>
                        </ach-name>
                        <section-1>
                            <label>Untitled Section</label>
                        </section-1>
                       
                    </resource>
                </resources>
            </xf:instance>

           
            <xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
                <request/>
            </xf:instance>

            <xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
                <response/>
            </xf:instance>
            <xf:instance xxf:readonly="true" id="repeatable-grid-template">
                <repeatable-grid-iteration>
                    <select-repeatable-radio-button/>
                    <credit-card-number/>
                    <credit-card-name/>
                    <ach-number/>
                    <ach-name/>
                </repeatable-grid-iteration>
            </xf:instance>

            <xf:action id="on-change-repeatable-radio-button-binding">
               
                <xf:action ev:event="xforms-value-changed"
                           ev:observer="select-repeatable-radio-button-control"
                           if="instance('fr-form-instance')/section-1/repeatable-grid/repeatable-grid-iteration/select-repeatable-radio-button = '1'">
                                                   
                                                                     <xf:setvalue ref="instance('fr-form-instance')/section-1/repeatable-grid/repeatable-grid-iteration/ach-number"
                                 value=""/>
                                                                     <xf:setvalue ref="instance('fr-form-instance')/section-1/repeatable-grid/repeatable-grid-iteration/ach-name"
                                 value=""/>
                                                       
                   
                    <xf:send submission="SET ME"/>
                </xf:action>
                                <xf:action ev:event="xforms-value-changed"
                           ev:observer="select-repeatable-radio-button-control"
                           if="instance('fr-form-instance')/section-1/repeatable-grid/repeatable-grid-iteration/select-repeatable-radio-button = '2'">
                                                   
                                                                     <xf:setvalue ref="instance('fr-form-instance')/section-1/repeatable-grid/repeatable-grid-iteration/credit-card-number"
                                 value=""/>
                                                                     <xf:setvalue ref="instance('fr-form-instance')/section-1/repeatable-grid/repeatable-grid-iteration/credit-card-name"
                                 value=""/>
                                                       
                   
                    <xf:send submission="SET ME"/>
                </xf:action>
               
                <xf:action ev:event="xforms-submit" ev:observer="SET ME">
                   
                    <xf:var name="request-instance-name" value="'-instance'" as="xs:string"/>
                   
                    <xf:insert ref="instance('fr-service-request-instance')"
                               origin="saxon:parse(instance($request-instance-name))"/>
                   
                   
                    <xf:action context="instance('fr-service-request-instance')">
                       
                    </xf:action>
                </xf:action>
               
                <xf:action ev:event="xforms-submit-done" ev:observer="SET ME"
                           context="instance('fr-service-response-instance')">
                   
                </xf:action>
            </xf:action>
        </xf:model>
    </xh:head>
    <xh:body>
        <fr:view>
            <fr:body xmlns:oxf="http://www.orbeon.com/oxf/processors"
                     xmlns:p="http://www.orbeon.com/oxf/pipeline"
                     xmlns:xbl="http://www.w3.org/ns/xbl">
                <fr:section id="section-1-control" bind="section-1-bind">
                    <xf:label ref="$form-resources/section-1/label"/>
                    <fr:grid id="repeatable-grid-control" bind="repeatable-grid-bind" repeat="content"
                             min="1"
                             template="instance('repeatable-grid-template')">
                        <xh:tr>
                            <xh:td>
                                <xf:select1 id="select-repeatable-radio-button-control" appearance="full"
                                            bind="select-repeatable-radio-button-bind">
                                    <xf:label ref="$form-resources/select-repeatable-radio-button/label"/>
                                    <xf:hint ref="$form-resources/select-repeatable-radio-button/hint"/>
                                    <xf:alert ref="$fr-resources/detail/labels/alert"/>
                       
                       
                                    <xf:itemset ref="$form-resources/select-repeatable-radio-button/item">
                                        <xf:label ref="label"/>
                                        <xf:value ref="value"/>
                                        <xf:hint ref="hint"/>
                                    </xf:itemset>
                                </xf:select1>
                            </xh:td>
                            <xh:td/>
                        </xh:tr>
                        <xh:tr>
                            <xh:td>
                                <xf:input id="credit-card-number-control" bind="credit-card-number-bind">
                                    <xf:label ref="$form-resources/credit-card-number/label"/>
                                    <xf:hint ref="$form-resources/credit-card-number/hint"/>
                                    <xf:alert ref="$fr-resources/detail/labels/alert"/>
                       
                       
                                </xf:input>
                            </xh:td>
                            <xh:td>
                                <xf:input id="credit-card-name-control" bind="credit-card-name-bind">
                                    <xf:label ref="$form-resources/credit-card-name/label"/>
                                    <xf:hint ref="$form-resources/credit-card-name/hint"/>
                                    <xf:alert ref="$fr-resources/detail/labels/alert"/>
                       
                       
                                </xf:input>
                            </xh:td>
                        </xh:tr>
                        <xh:tr>
                            <xh:td>
                                <xf:input id="ach-number-control" bind="ach-number-bind">
                                    <xf:label ref="$form-resources/ach-number/label"/>
                                    <xf:hint ref="$form-resources/ach-number/hint"/>
                                    <xf:alert ref="$fr-resources/detail/labels/alert"/>
                       
                       
                                </xf:input>
                            </xh:td>
                            <xh:td>
                                <xf:input id="ach-name-control" bind="ach-name-bind">
                                    <xf:label ref="$form-resources/ach-name/label"/>
                                    <xf:hint ref="$form-resources/ach-name/hint"/>
                                    <xf:alert ref="$fr-resources/detail/labels/alert"/>
                       
                       
                                </xf:input>
                            </xh:td>
                        </xh:tr>
                    </fr:grid>
                </fr:section>
            </fr:body>
        </fr:view>
    </xh:body>
</xh:html>


Please have a look of code.

Let me know if you need any more information.
Reply | Threaded
Open this post in threaded view
|

Re: Added action in Repeatable grid is not working for another grid iteration?

Alessandro  Vernet
Administrator
Hi Vikash,

So you are saying that this is with Orbeon Forms 4.9, correct? I can't run your form as-is because it contains some "SET ME" placeholders. Would you be able to update it to point to a test service so we can run your test here, as mentioned in my previous message?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Added action in Repeatable grid is not working for another grid iteration?

Rajeeva Lochana BR
This post was updated on .
In reply to this post by vikash kumar
Hi Vikash,


Use the below condition in "Calculated Value" which sets the default value based on your condition.

if ($select-repeatable-radio-button='2') then . else ''


For more information find the attached example code.
field-clear-function.txt